diff options
Diffstat (limited to 'src/settings/plugins/ifnet/wpa_parser.c')
| -rw-r--r-- | src/settings/plugins/ifnet/wpa_parser.c | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/src/settings/plugins/ifnet/wpa_parser.c b/src/settings/plugins/ifnet/wpa_parser.c index 501bca7a..8e2559b3 100644 --- a/src/settings/plugins/ifnet/wpa_parser.c +++ b/src/settings/plugins/ifnet/wpa_parser.c @@ -365,7 +365,7 @@ gboolean wpa_flush_to_file (const char *config_file) { GIOChannel *channel; - GError **error = NULL; + GError *error = NULL; gpointer key, value, ssid, security; GHashTableIter iter, iter_security; gchar *out_line; @@ -389,25 +389,27 @@ wpa_flush_to_file (const char *config_file) g_io_channel_write_chars (channel, "#Generated by NetworkManager\n" "###### Global Configuration ######\n", - -1, &bytes_written, error); + -1, &bytes_written, &error); + if (error) + goto done; /* Writing global information */ while (g_hash_table_iter_next (&iter, &key, &value)) { out_line = g_strdup_printf ("%s=%s\n", (gchar *) key, (gchar *) value); g_io_channel_write_chars (channel, out_line, -1, &bytes_written, - error); - if (bytes_written == 0 || (error && *error)) + &error); + if (bytes_written == 0 || error) break; g_free (out_line); } - if (error && *error) { - nm_log_warn (LOGD_SETTINGS, "Found error: %s", (*error)->message); + if (error) goto done; - } g_io_channel_write_chars (channel, "\n###### Security Configuration ######\n", - -1, &bytes_written, error); + -1, &bytes_written, &error); + if (error) + goto done; g_hash_table_iter_init (&iter, wsec_table); /* Writing security */ @@ -415,35 +417,34 @@ wpa_flush_to_file (const char *config_file) g_hash_table_iter_init (&iter_security, (GHashTable *) security); g_io_channel_write_chars (channel, "network={\n", -1, - &bytes_written, error); + &bytes_written, &error); + if (error) + goto done; while (g_hash_table_iter_next (&iter_security, &key, &value)) { out_line = g_strdup_printf (need_quote ((gchar *) key) ? "\t%s=\"%s\"\n" : "\t%s=%s\n", (gchar *) key, (gchar *) value); g_io_channel_write_chars (channel, out_line, -1, - &bytes_written, error); - if (bytes_written == 0 || (error && *error)) - break; + &bytes_written, &error); + if (bytes_written == 0 || error) + goto done; g_free (out_line); } - g_io_channel_write_chars (channel, - "}\n\n", -1, &bytes_written, error); + g_io_channel_write_chars (channel, "}\n\n", -1, &bytes_written, &error); } - if (error && *error) { - nm_log_warn (LOGD_SETTINGS, "Found error: %s", (*error)->message); + g_io_channel_flush (channel, &error); + if (error) goto done; - } - g_io_channel_flush (channel, error); - if (error && *error) { - nm_log_warn (LOGD_SETTINGS, "Found error: %s", (*error)->message); - goto done; - } wpa_parser_data_changed = FALSE; result = TRUE; done: + if (error) { + nm_log_warn (LOGD_SETTINGS, "Error writing WPA configuration: %s", error->message); + g_error_free (error); + } g_io_channel_shutdown (channel, FALSE, NULL); g_io_channel_unref (channel); return result; |