Fix dlog format error
[platform/core/connectivity/net-config.git] / src / utils / util.c
index 3c1c60a..d80c743 100755 (executable)
@@ -428,8 +428,8 @@ int netconfig_execute_file(const char *file_path,
 
                errno = 0;
                if (execve(file_path, args, envs) == -1) {
-                       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-                       DBG("Fail to execute command (%s)", error_buf);
+                       DBG("Fail to execute command (%s)",
+                                       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
                        exit(1);
                }
        } else if (pid > 0) {
@@ -450,8 +450,8 @@ int netconfig_execute_file(const char *file_path,
                return rv;
        }
 
-       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-       DBG("failed to fork(%s)", error_buf);
+       DBG("failed to fork(%s)",
+               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
        return -EIO;
 }
 
@@ -476,8 +476,8 @@ int netconfig_execute_cmd(const char *cmd)
 
                errno = 0;
                if (execv(args[0], args) == -1) {
-                       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-                       DBG("Fail to execute command (%s)", error_buf);
+                       DBG("Fail to execute command (%s)",
+                               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
                        g_strfreev(args);
                        exit(1);
                }
@@ -500,8 +500,8 @@ int netconfig_execute_cmd(const char *cmd)
                return rv;
        }
 
-       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-       DBG("failed to fork(%s)", error_buf);
+       DBG("failed to fork(%s)",
+               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
        g_strfreev(args);
 
        return -EIO;
@@ -534,7 +534,7 @@ int netconfig_execute_clatd(const char *file_path, char *const args[])
 
        state = sigaction(SIGCHLD, &act, 0);
        if (state != 0) {
-               DBG("sigaction() : %d");
+               DBG("sigaction() : %d", state);
                return -1;
        }
 
@@ -549,8 +549,8 @@ int netconfig_execute_clatd(const char *file_path, char *const args[])
 
                errno = 0;
                if (execvp(file_path, args) == -1) {
-                       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-                       ERR("Fail to execute command (%s)", error_buf);
+                       ERR("Fail to execute command (%s)",
+                               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
                        return -1;
                }
        } else if (pid > 0) {
@@ -558,8 +558,8 @@ int netconfig_execute_clatd(const char *file_path, char *const args[])
                return rv;
        }
 
-       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-       DBG("failed to fork(%s)", error_buf);
+       DBG("failed to fork(%s)",
+               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
        return -EIO;
 }
 
@@ -582,6 +582,7 @@ int netconfig_execute_file_no_wait(const char *file_path, char *const args[])
 
        struct sigaction act;
        int state = 0;
+       char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
 
        act.sa_handler = no_wait_signal_handler;
        sigemptyset(&act.sa_mask);
@@ -589,7 +590,7 @@ int netconfig_execute_file_no_wait(const char *file_path, char *const args[])
 
        state = sigaction(SIGCHLD, &act, 0);
        if (state != 0) {
-               DBG("sigaction() : %d");
+               DBG("sigaction() : %d", state);
                return -1;
        }
 
@@ -604,7 +605,8 @@ int netconfig_execute_file_no_wait(const char *file_path, char *const args[])
 
                errno = 0;
                if (execvp(file_path, args) == -1) {
-                       ERR("Fail to execute command (%s)", strerror(errno));
+                       ERR("Fail to execute command (%s)",
+                               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
                        return -1;
                }
        } else if (pid > 0) {
@@ -612,7 +614,8 @@ int netconfig_execute_file_no_wait(const char *file_path, char *const args[])
                return rv;
        }
 
-       DBG("failed to fork(%s)", strerror(errno));
+       DBG("failed to fork(%s)",
+               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
        return -EIO;
 }
 
@@ -631,8 +634,8 @@ int __netconfig_get_interface_index(const char *interface_name)
        errno = 0;
        sock = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
        if (sock < 0) {
-               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-               DBG("Failed to create socket : %s", error_buf);
+               DBG("Failed to create socket : %s",
+                       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
                return -1;
        }
 
@@ -642,8 +645,8 @@ int __netconfig_get_interface_index(const char *interface_name)
        close(sock);
 
        if (result < 0) {
-               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-               DBG("Failed to get ifr index: %s", error_buf);
+               DBG("Failed to get ifr index: %s",
+                       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
                return -1;
        }
 
@@ -691,14 +694,14 @@ int netconfig_add_route_ipv4(gchar *ip_addr, gchar *subnet, gchar *interface, gi
        sock = socket(PF_INET, SOCK_DGRAM, 0);
 
        if (sock < 0) {
-               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-               DBG("Failed to create socket : %s", error_buf);
+               DBG("Failed to create socket : %s",
+                       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
                return -1;
        }
 
        if (ioctl(sock, SIOCADDRT, &rt) < 0) {
-               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-               DBG("Failed to set route address : %s", error_buf);
+               DBG("Failed to set route address : %s",
+                       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
                close(sock);
                return -1;
        }
@@ -742,14 +745,14 @@ int netconfig_del_route_ipv4(gchar *ip_addr, gchar *subnet, gchar *interface, gi
        sock = socket(PF_INET, SOCK_DGRAM, 0);
 
        if (sock < 0) {
-               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-               DBG("Failed to create socket : %s", error_buf);
+               DBG("Failed to create socket : %s",
+                       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
                return -1;
        }
 
        if (ioctl(sock, SIOCDELRT, &rt) < 0) {
-               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-               DBG("Failed to set route address : %s", error_buf);
+               DBG("Failed to set route address : %s",
+                       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
                close(sock);
                return -1;
        }
@@ -774,16 +777,16 @@ int netconfig_add_route_ipv6(gchar *ip_addr, gchar *interface, gchar *gateway, u
 
        errno = 0;
        if (inet_pton(AF_INET6, ip_addr, &rt.rtmsg_dst) < 0) {
-               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-               DBG("inet_pton failed : %s", error_buf);
+               DBG("inet_pton failed : %s",
+                       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
                return -1;
        }
 
        if (gateway != NULL) {
                rt.rtmsg_flags |= RTF_GATEWAY;
                if (inet_pton(AF_INET6, gateway, &rt.rtmsg_gateway) < 0) {
-                       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-                       DBG("inet_pton failed : %s", error_buf);
+                       DBG("inet_pton failed : %s",
+                               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
                        return -1;
                }
        }
@@ -792,8 +795,8 @@ int netconfig_add_route_ipv6(gchar *ip_addr, gchar *interface, gchar *gateway, u
 
        fd = socket(AF_INET6, SOCK_DGRAM, 0);
        if (fd < 0) {
-               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-               DBG("Failed to create socket : %s", error_buf);
+               DBG("Failed to create socket : %s",
+                       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
                return -1;
        }
 
@@ -808,8 +811,8 @@ int netconfig_add_route_ipv6(gchar *ip_addr, gchar *interface, gchar *gateway, u
        }
 
        if ((err = ioctl(fd, SIOCADDRT, &rt)) < 0) {
-               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-               DBG("Failed to add route: %s", error_buf);
+               DBG("Failed to add route: %s",
+                       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
                close(fd);
                return -1;
        }
@@ -975,7 +978,7 @@ gboolean handle_launch_mdns(Network *object, GDBusMethodInvocation *context,
        if (execute_mdnsd_script("start") < 0) {
                ERR("Failed to launch mdnsresponder daemon");
                netconfig_error_invalid_parameter(context);
-               return FALSE;
+               return TRUE;
        }
 
        mdnsd_ref_count++;
@@ -1344,6 +1347,9 @@ bool netconfig_check_feature_supported(netconfig_supported_feature_e feature)
                case NETCONFIG_SUPPORTED_FEATURE_WIFI_DIRECT:
                        key = WIFI_DIRECT_FEATURE;
                        break;
+               case NETCONFIG_SUPPORTED_FEATURE_WIFI_SOFTAP:
+                       key = WIFI_SOFTAP_FEATURE;
+                       break;
                default:
                        ERR("Uknown feature");
                        return false;