From 683f1407398dd7b042c524b3fd27352c1eea113d Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Mon, 25 Oct 2021 12:41:20 +0300 Subject: IPCDevice: use thread safe strerror_r() instead of strerror() Change-Id: Ia51ffa51ec7729572faca0282ae41c1e4968049f --- Transceiver52M/device/ipc/IPCDevice.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 @@ IPCDevice::~IPCDevice() 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 @@ int IPCDevice::ipc_shm_connect(const char *shm_name) // 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 @@ int IPCDevice::ipc_shm_connect(const char *shm_name) 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; } -- cgit v1.2.3