Change in osmo-trx[master]: IPCDevice: use thread safe strerror_r() instead of strerror()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

fixeria gerrit-no-reply at lists.osmocom.org
Tue Oct 26 16:17:31 UTC 2021


fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-trx/+/25936 )

Change subject: IPCDevice: use thread safe strerror_r() instead of strerror()
......................................................................

IPCDevice: use thread safe strerror_r() instead of strerror()

Change-Id: Ia51ffa51ec7729572faca0282ae41c1e4968049f
---
M Transceiver52M/device/ipc/IPCDevice.cpp
1 file changed, 7 insertions(+), 3 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  osmith: Looks good to me, approved



diff --git a/Transceiver52M/device/ipc/IPCDevice.cpp b/Transceiver52M/device/ipc/IPCDevice.cpp
index 5ed428e..c1c6449 100644
--- a/Transceiver52M/device/ipc/IPCDevice.cpp
+++ b/Transceiver52M/device/ipc/IPCDevice.cpp
@@ -100,12 +100,14 @@
 int IPCDevice::ipc_shm_connect(const char *shm_name)
 {
 	int fd;
+	char err_buf[256];
 	size_t shm_len;
 	int rc;
 
 	LOGP(DDEV, LOGL_NOTICE, "Opening shm path %s\n", shm_name);
 	if ((fd = shm_open(shm_name, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) < 0) {
-		LOGP(DDEV, LOGL_ERROR, "shm_open %d: %s\n", errno, strerror(errno));
+		LOGP(DDEV, LOGL_ERROR, "shm_open %d: %s\n", errno,
+		     strerror_r(errno, err_buf, sizeof(err_buf)));
 		rc = -errno;
 		goto err_shm_open;
 	}
@@ -113,7 +115,8 @@
 	// Get size of the allocated memory
 	struct stat shm_stat;
 	if (fstat(fd, &shm_stat) < 0) {
-		LOGP(DDEV, LOGL_ERROR, "fstat %d: %s\n", errno, strerror(errno));
+		LOGP(DDEV, LOGL_ERROR, "fstat %d: %s\n", errno,
+		     strerror_r(errno, err_buf, sizeof(err_buf)));
 		rc = -errno;
 		goto err_mmap;
 	}
@@ -122,7 +125,8 @@
 
 	LOGP(DDEV, LOGL_NOTICE, "mmaping shared memory fd %d (size=%zu)\n", fd, shm_len);
 	if ((shm = mmap(NULL, shm_len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) {
-		LOGP(DDEV, LOGL_ERROR, "mmap %d: %s\n", errno, strerror(errno));
+		LOGP(DDEV, LOGL_ERROR, "mmap %d: %s\n", errno,
+		     strerror_r(errno, err_buf, sizeof(err_buf)));
 		rc = -errno;
 		goto err_mmap;
 	}

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/25936
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Change-Id: Ia51ffa51ec7729572faca0282ae41c1e4968049f
Gerrit-Change-Number: 25936
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211026/1d5a04d0/attachment.htm>


More information about the gerrit-log mailing list