From 6cd03bf205745bf13ec3a9af7af30a376e348015 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 26 Mar 2016 12:26:54 +0100 Subject: [PATCH] libnm-util: refactor hash_to_connection() No functional change, only move the verify-step out of hash_to_connection(). --- libnm-util/nm-connection.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c index daeee46b7..f77e32230 100644 --- a/libnm-util/nm-connection.c +++ b/libnm-util/nm-connection.c @@ -327,13 +327,13 @@ validate_permissions_type (GHashTable *hash, GError **error) return TRUE; } -static gboolean -hash_to_connection (NMConnection *connection, GHashTable *new, GError **error) +static void +hash_to_connection (NMConnection *connection, GHashTable *new) { GHashTableIter iter; const char *setting_name; GHashTable *setting_hash; - gboolean changed, valid; + gboolean changed; NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (connection); if ((changed = g_hash_table_size (priv->settings) > 0)) @@ -353,10 +353,8 @@ hash_to_connection (NMConnection *connection, GHashTable *new, GError **error) } } - valid = nm_connection_verify (connection, error); if (changed) g_signal_emit (connection, signals[CHANGED], 0); - return valid; } /** @@ -373,16 +371,16 @@ nm_connection_replace_settings (NMConnection *connection, GHashTable *new_settings, GError **error) { - gboolean valid = FALSE; - g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE); g_return_val_if_fail (new_settings != NULL, FALSE); if (error) g_return_val_if_fail (*error == NULL, FALSE); - if (validate_permissions_type (new_settings, error)) - valid = hash_to_connection (connection, new_settings, error); - return valid; + if (!validate_permissions_type (new_settings, error)) + return FALSE; + + hash_to_connection (connection, new_settings); + return nm_connection_verify (connection, error); } /** @@ -1466,10 +1464,9 @@ nm_connection_new_from_hash (GHashTable *hash, GError **error) return NULL; connection = nm_connection_new (); - if (!hash_to_connection (connection, hash, error)) { - g_object_unref (connection); - return NULL; - } + hash_to_connection (connection, hash); + if (!nm_connection_verify (connection, error)) + g_clear_object (&connection); return connection; } -- 2.17.1