Fixed build error on gcc62
[platform/core/connectivity/net-config.git] / src / wifi-config.c
index 9a910e8..41297d5 100755 (executable)
@@ -103,41 +103,42 @@ static gboolean __get_mac_address(gchar **mac_address)
        gchar *tmp = NULL;
        gchar mac[13] = { 0, };
        gint i = 0, j = 0;
-#if defined TIZEN_TV
-       FILE *fp = NULL;
-       char buf[WIFI_MAC_ADD_LENGTH + 1];
-       if (0 == access(WIFI_MAC_ADD_PATH, F_OK))
-               fp = fopen(WIFI_MAC_ADD_PATH, "r");
-
-       if (fp == NULL) {
-               ERR("Failed to open file %s\n", WIFI_MAC_ADD_PATH);
-               *mac_address = NULL;
-               return FALSE;
-       }
 
-       if (fgets(buf, sizeof(buf), fp) == NULL) {
-               ERR("Failed to get MAC info from %s\n", WIFI_MAC_ADD_PATH);
-               *mac_address = NULL;
-               fclose(fp);
-               return FALSE;
-       }
-       tmp_mac = (char *)g_try_malloc0(WIFI_MAC_ADD_LENGTH + 1);
-       if (tmp_mac == NULL) {
-               ERR("malloc() failed");
-               *mac_address = NULL;
+       if (TIZEN_TV) {
+               FILE *fp = NULL;
+               char buf[WIFI_MAC_ADD_LENGTH + 1];
+               if (0 == access(WIFI_MAC_ADD_PATH, F_OK))
+                       fp = fopen(WIFI_MAC_ADD_PATH, "r");
+
+               if (fp == NULL) {
+                       ERR("Failed to open file %s\n", WIFI_MAC_ADD_PATH);
+                       *mac_address = NULL;
+                       return FALSE;
+               }
+
+               if (fgets(buf, sizeof(buf), fp) == NULL) {
+                       ERR("Failed to get MAC info from %s\n", WIFI_MAC_ADD_PATH);
+                       *mac_address = NULL;
+                       fclose(fp);
+                       return FALSE;
+               }
+               tmp_mac = (char *)g_try_malloc0(WIFI_MAC_ADD_LENGTH + 1);
+               if (tmp_mac == NULL) {
+                       ERR("malloc() failed");
+                       *mac_address = NULL;
+                       fclose(fp);
+                       return FALSE;
+               }
+               g_strlcpy(tmp_mac, buf, WIFI_MAC_ADD_LENGTH + 1);
                fclose(fp);
-               return FALSE;
-       }
-       g_strlcpy(tmp_mac, buf, WIFI_MAC_ADD_LENGTH + 1);
-       fclose(fp);
-#else
-       tmp_mac = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
-       if (tmp_mac == NULL) {
-               ERR("vconf_get_str(WIFI_BSSID_ADDRESS) Failed");
-               *mac_address = NULL;
-               return FALSE;
+       } else {
+               tmp_mac = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
+               if (tmp_mac == NULL) {
+                       ERR("vconf_get_str(WIFI_BSSID_ADDRESS) Failed");
+                       *mac_address = NULL;
+                       return FALSE;
+               }
        }
-#endif
        tmp = g_ascii_strdown(tmp_mac, (gssize)strlen(tmp_mac));
        g_free(tmp_mac);
        while (tmp && tmp[i]) {
@@ -431,6 +432,7 @@ static gboolean _set_field(const gchar *config_id, const gchar *key, const gchar
        keyfile = __get_configuration_keyfile(group_name);
        if (keyfile == NULL) {
                ERR("Fail to __get_configuration_keyfile");
+               g_free(group_name);
                return FALSE;
        }
 
@@ -490,6 +492,7 @@ static gboolean _get_field(const gchar *config_id, const gchar *key, gchar **val
        keyfile = __get_configuration_keyfile(group_name);
        if (keyfile == NULL) {
                ERR("Fail to __get_configuration_keyfile");
+               g_free(group_name);
                return FALSE;
        }
 
@@ -540,7 +543,6 @@ static gboolean _get_field(const gchar *config_id, const gchar *key, gchar **val
 static GSList *_get_list(void)
 {
        GSList *list = NULL;
-       struct dirent ent_struct;
        struct dirent *dp = NULL;
        DIR *dir;
 
@@ -550,7 +552,7 @@ static GSList *_get_list(void)
                return NULL;
        }
 
-       while ((readdir_r(dir, &ent_struct, &dp) == 0) && dp) {
+       while ((readdir(dir) == 0) && (dp != NULL)) {
                if (g_strcmp0(dp->d_name, ".") == 0 || g_strcmp0(dp->d_name, "..") == 0 ||
                                strncmp(dp->d_name, WIFI_CONFIG_PREFIX, strlen(WIFI_CONFIG_PREFIX)) != 0) {
                        continue;
@@ -738,6 +740,12 @@ gboolean handle_save_configuration(Wifi *wifi, GDBusMethodInvocation *context,
 
        ret = __get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
        if (ret != TRUE) {
+               g_free(conf->name);
+               g_free(conf->ssid);
+               g_free(conf->passphrase);
+               g_free(conf->is_hidden);
+               g_free(conf->proxy_address);
+               g_free(conf);
                ERR("Fail to get_wifi_config_group_name");
                return FALSE;
        }