summaryrefslogtreecommitdiff
path: root/libnm-util/nm-connection.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-03-26 12:26:54 +0100
committerThomas Haller <thaller@redhat.com>2016-03-29 11:56:27 +0200
commit6cd03bf205745bf13ec3a9af7af30a376e348015 (patch)
treee08803f4d634c5e33c94cdc0018b659864a708d2 /libnm-util/nm-connection.c
parentf8a6b13369cdaf73d28e069e00b6185967eca5ad (diff)
downloadNetworkManager-6cd03bf205745bf13ec3a9af7af30a376e348015.tar.gz
libnm-util: refactor hash_to_connection()
No functional change, only move the verify-step out of hash_to_connection().
Diffstat (limited to 'libnm-util/nm-connection.c')
-rw-r--r--libnm-util/nm-connection.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c
index daeee46b7e..f77e322307 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;
}