Fix svace issue [WGID: 378746]. 12/193312/2 accepted/tizen/unified/20181122.160707 submit/tizen/20181122.014958
authorNiraj Kumar Goit <niraj.g@samsung.com>
Mon, 19 Nov 2018 07:13:20 +0000 (12:43 +0530)
committerNiraj Kumar Goit <niraj.g@samsung.com>
Mon, 19 Nov 2018 09:06:06 +0000 (14:36 +0530)
Use strerror_r function instead of strerror for thread safety.

Change-Id: Ib75cded4baaab3ae1862e594f409df9ec6511e71
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
src/wifi-power.c

index c900012..c1e4aaf 100755 (executable)
@@ -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;
        }