Fix dlog format error
[platform/core/connectivity/net-config.git] / src / wifi-eap-config.c
index 25a2699..99d406b 100755 (executable)
@@ -94,7 +94,7 @@ static int __config_save(const char *ssid, GKeyFile *keyfile)
 
        /* Do POSIX file operation to create and remove config files,
         * Do not use g_file_set_contents, it breaks inotify operations */
-       if (fputs(data, file) < 0) {
+       if (data && fputs(data, file) < 0) {
                ERR("Failed to write %s", config_file);
 
                err = -EIO;
@@ -196,7 +196,7 @@ static gboolean __netconfig_copy_config(const char *src, const char *dst)
 
        result = g_file_get_contents(src, &buf, &length, &error);
        if (result != TRUE) {
-               ERR("Failed to read %s[%s]", error->message);
+               ERR("Failed to read [%s]", error->message);
                g_error_free(error);
 
                return result;
@@ -204,7 +204,7 @@ static gboolean __netconfig_copy_config(const char *src, const char *dst)
 
        result = g_file_set_contents(dst, buf, length, &error);
        if (result != TRUE) {
-               ERR("Failed to write %s[%s]", error->message);
+               ERR("Failed to write [%s]", error->message);
                g_error_free(error);
        }
 
@@ -366,13 +366,11 @@ static gboolean _delete_configuration(const gchar *profile)
        ERR("get config_id [%s] from [%s]", config_id, profile);
 
        ret = wifi_config_remove_configuration(config_id);
-       if (ret != TRUE) {
+       if (ret != TRUE)
                ERR("Fail to wifi_config_remove_configuration [%s]", config_id);
-       }
 
-       if (config_id != NULL) {
+       if (config_id != NULL)
                g_free(config_id);
-       }
 
        return ret;
 }
@@ -391,9 +389,8 @@ static gboolean __netconfig_delete_config(const char *profile)
                return FALSE;
        }
 
-       if (_delete_configuration(profile) != TRUE) {
+       if (_delete_configuration(profile) != TRUE)
                ERR("Fail to delete configuration [%s]", profile);
-       }
 
        wifi_ident = strstr(profile, "wifi_");
        if (wifi_ident == NULL) {
@@ -466,16 +463,15 @@ gboolean handle_create_eap_config(Wifi *wifi, GDBusMethodInvocation *context,
                const gchar *service, GVariant *fields)
 {
        gboolean updated = FALSE;
-       gboolean reply = FALSE;
        gboolean result = FALSE;
 
-       g_return_val_if_fail(wifi != NULL, FALSE);
+       g_return_val_if_fail(wifi != NULL, TRUE);
 
        DBG("Set agent fields for %s", service);
 
        if (netconfig_is_wifi_profile(service) != TRUE) {
                netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_WRONG_PROFILE, "InvalidService");
-               return reply;
+               return TRUE;
        }
 
        updated = __netconfig_create_config(fields);
@@ -527,20 +523,18 @@ gboolean handle_create_eap_config(Wifi *wifi, GDBusMethodInvocation *context,
 
        if (result != TRUE)
                ERR("Fail to connect %s", service);
-       else
-               reply = TRUE;
 
-       return reply;
+       return TRUE;
 }
 
 gboolean handle_delete_eap_config(Wifi *wifi, GDBusMethodInvocation *context,
                const gchar *profile)
 {
-       g_return_val_if_fail(wifi != NULL, FALSE);
+       g_return_val_if_fail(wifi != NULL, TRUE);
 
        wifi_complete_delete_eap_config(wifi, context);
 
-       gboolean ret = __netconfig_delete_config((const char *)profile);
+       __netconfig_delete_config((const char *)profile);
 
-       return ret;
+       return TRUE;
 }