From ded231dd88eab8bf6e04b0f912a320e8de707a62 Mon Sep 17 00:00:00 2001 From: Niraj Kumar Goit Date: Mon, 19 Nov 2018 12:43:20 +0530 Subject: [PATCH] Fix svace issue [WGID: 378746]. Use strerror_r function instead of strerror for thread safety. Change-Id: Ib75cded4baaab3ae1862e594f409df9ec6511e71 Signed-off-by: Niraj Kumar Goit --- src/wifi-power.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/wifi-power.c b/src/wifi-power.c index c900012..c1e4aaf 100755 --- a/src/wifi-power.c +++ b/src/wifi-power.c @@ -517,6 +517,7 @@ void wifi_set_early_suspend(gboolean value) int ioctl_sock = 0; int pm_state = 0; wifi_service_state_e wifi_state; + char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, }; if (old_state == value) { DBG("Old and new states are same"); @@ -552,15 +553,17 @@ void wifi_set_early_suspend(gboolean value) ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0); if (ioctl_sock < 0) { - DBG("socket(PF_INET,SOCK_DGRAM) failed"); + strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER); + DBG("socket(PF_INET,SOCK_DGRAM) failed: %s", error_buf); return; } ret = ioctl(ioctl_sock, WLAN_IOCTL_SUSPEND, &ifr); - if (ret < 0) - ERR("Fail to issue private commands: %d. %s", ret, strerror(errno)); - else { + if (ret < 0) { + strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER); + ERR("Fail to issue private commands: %d. %s", ret, error_buf); + } else { old_state = value; } -- 2.7.4