Fix coverity issue (1025915). 88/188888/1
authorNiraj Kumar Goit <niraj.g@samsung.com>
Tue, 11 Sep 2018 09:54:07 +0000 (15:24 +0530)
committerNiraj Kumar Goit <niraj.g@samsung.com>
Tue, 11 Sep 2018 09:54:07 +0000 (15:24 +0530)
Change-Id: I51b5cab5bc94232c7a389a5632863cb75cc23c79
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
src/wifi-config.c

index 79260c3..3b01143 100755 (executable)
@@ -347,13 +347,14 @@ static gboolean _load_configuration(const gchar *config_id, struct wifi_config *
        DBG("is_hidden [%s]", config->is_hidden);
 
        if (config->ip_info) {
+               GError *error = NULL;
                config->ip_info->ip_type = g_key_file_get_string(keyfile, group_name,
-                                                                                        WIFI_CONFIG_IPV4_METHOD, NULL);
+                               WIFI_CONFIG_IPV4_METHOD, NULL);
                if (config->ip_info->ip_type)
                        DBG("IPv4.Method:%s", config->ip_info->ip_type);
 
                config->ip_info->ip_address = g_key_file_get_string(keyfile, group_name,
-                                                                                       WIFI_CONFIG_IPV4_ADDRESS, NULL);
+                               WIFI_CONFIG_IPV4_ADDRESS, NULL);
                if (config->ip_info->ip_address)
                        DBG("IPv4.Address:%s", config->ip_info->ip_address);
 
@@ -362,13 +363,18 @@ static gboolean _load_configuration(const gchar *config_id, struct wifi_config *
                struct in_addr netmask;
                char *mask;
                prefix_len = g_key_file_get_integer(keyfile, group_name,
-                                                                                       WIFI_CONFIG_IPV4_SUBNET_MASK, NULL);
-               addr = 0xffffffff << (32 - prefix_len);
-               netmask.s_addr = htonl(addr);
-               mask = inet_ntoa(netmask);
-               config->ip_info->subnet_mask = g_strdup(mask);
-               if (config->ip_info->subnet_mask)
-                       DBG("IPv4.SubnetMask:%s", config->ip_info->subnet_mask);
+                               WIFI_CONFIG_IPV4_SUBNET_MASK, &error);
+               if (error != NULL) {
+                       DBG("g_key_file_get_integer failed error[%d: %s]", error->code, error->message);
+                       g_error_free(error);
+               } else {
+                       addr = 0xffffffff << (32 - prefix_len);
+                       netmask.s_addr = htonl(addr);
+                       mask = inet_ntoa(netmask);
+                       config->ip_info->subnet_mask = g_strdup(mask);
+                       if (config->ip_info->subnet_mask)
+                               DBG("IPv4.SubnetMask:%s", config->ip_info->subnet_mask);
+               }
 
                config->ip_info->gateway_address = g_key_file_get_string(keyfile,
                                                        group_name, WIFI_CONFIG_IPV4_GATEWAY_ADDRESS, NULL);