diff options
Diffstat (limited to 'src/settings/plugins/ifnet/net_parser.c')
| -rw-r--r-- | src/settings/plugins/ifnet/net_parser.c | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/src/settings/plugins/ifnet/net_parser.c b/src/settings/plugins/ifnet/net_parser.c index cad34f06..6e1061c6 100644 --- a/src/settings/plugins/ifnet/net_parser.c +++ b/src/settings/plugins/ifnet/net_parser.c @@ -552,7 +552,7 @@ gboolean ifnet_flush_to_file (const char *config_file, gchar **out_backup) { GIOChannel *channel; - GError **error = NULL; + GError *error = NULL; gpointer key, value, name, network; GHashTableIter iter, iter_network; GList *list_iter; @@ -579,32 +579,36 @@ ifnet_flush_to_file (const char *config_file, gchar **out_backup) 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 data */ 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)) - break; + &bytes_written, &error); + if (bytes_written == 0 || error) + goto done; g_free (out_line); } - if (error && *error) { - nm_log_warn (LOGD_SETTINGS, "Found error: %s", (*error)->message); - goto done; - } /* Writing connection data */ g_io_channel_write_chars (channel, "\n###### Connection Configuration ######\n", - -1, &bytes_written, error); + -1, &bytes_written, &error); + if (error) + goto done; + g_hash_table_iter_init (&iter, conn_table); while (g_hash_table_iter_next (&iter, &name, &network)) { g_hash_table_iter_init (&iter_network, (GHashTable *) network); g_io_channel_write_chars (channel, "#----------------------------------\n", - -1, &bytes_written, error); + -1, &bytes_written, &error); + if (error) + goto done; while (g_hash_table_iter_next (&iter_network, &key, &value)) { if (!g_str_has_prefix ((gchar *) key, "name") @@ -627,51 +631,47 @@ ifnet_flush_to_file (const char *config_file, gchar **out_backup) ("%s_%s=\"%s\"\n", (gchar *) key, (gchar *) name, (gchar *) value); - g_io_channel_write_chars - (channel, out_line, -1, - &bytes_written, error); - if (bytes_written == 0 || (error && *error)) - break; + g_io_channel_write_chars (channel, out_line, -1, &bytes_written, &error); + if (bytes_written == 0 || error) + goto done; g_free (out_line); } } } - if (error && *error) { - nm_log_warn (LOGD_SETTINGS, "Found error: %s", (*error)->message); - goto done; - } /* Writing reserved functions */ if (functions_list) { g_io_channel_write_chars (channel, "\n###### Reserved Functions ######\n", - -1, &bytes_written, error); + -1, &bytes_written, &error); + if (error) + goto done; + /* Writing functions */ for (list_iter = functions_list; list_iter; list_iter = g_list_next (list_iter)) { out_line = g_strdup_printf ("%s\n", (gchar *) list_iter->data); 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); } - if (error && *error) { - nm_log_warn (LOGD_SETTINGS, "Found error: %s", (*error)->message); - goto done; - } } - g_io_channel_flush (channel, error); - if (error && *error) { - nm_log_warn (LOGD_SETTINGS, "Found error: %s", (*error)->message); + g_io_channel_flush (channel, &error); + if (error) goto done; - } result = TRUE; net_parser_data_changed = FALSE; done: + if (error) { + nm_log_warn (LOGD_SETTINGS, "Error writing the configuration file: %s", error->message); + g_error_free (error); + } + if (result && out_backup) *out_backup = backup; else |