summaryrefslogtreecommitdiff
path: root/src/nm-manager.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-12-19 17:35:17 +0100
committerThomas Haller <thaller@redhat.com>2019-01-14 11:55:17 +0100
commit3ae5c9d595c45b9253b9f1a2c3f56ebd2c9fb1d2 (patch)
tree8cf02c9421ec6d525d2ecbfbbd4051d3a13d59ff /src/nm-manager.c
parent2a6e7e917f9a567b7561dcfc9ff6de535861966f (diff)
downloadNetworkManager-3ae5c9d595c45b9253b9f1a2c3f56ebd2c9fb1d2.tar.gz
core: cleanup error path in activation_add_done()
Don't return success from a nested code path. Handle all errors first, and return early. Well, we cannot really return right away because we need to handle the failure. So, at least, check for errors and "goto fail".
Diffstat (limited to 'src/nm-manager.c')
-rw-r--r--src/nm-manager.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 2b14918683..945eb67233 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -5278,32 +5278,37 @@ activation_add_done (NMSettings *settings,
nm_utils_user_data_unpack (user_data, &self, &active, &persist_ptr);
persist = GPOINTER_TO_INT (persist_ptr);
- if (!error) {
- nm_active_connection_set_settings_connection (active, new_connection);
-
- if (_internal_activate_generic (self, active, &local)) {
- nm_settings_connection_update (new_connection,
- NULL,
- persist,
- NM_SETTINGS_CONNECTION_COMMIT_REASON_USER_ACTION | NM_SETTINGS_CONNECTION_COMMIT_REASON_ID_CHANGED,
- "add-and-activate",
- NULL);
- g_dbus_method_invocation_return_value (
- context,
- g_variant_new ("(oo)",
- nm_dbus_object_get_path (NM_DBUS_OBJECT (new_connection)),
- nm_dbus_object_get_path (NM_DBUS_OBJECT (active))));
- nm_audit_log_connection_op (NM_AUDIT_OP_CONN_ADD_ACTIVATE,
- nm_active_connection_get_settings_connection (active),
- TRUE,
- NULL,
- nm_active_connection_get_subject (active),
- NULL);
- return;
- }
+ if (error)
+ goto fail;
+
+ nm_active_connection_set_settings_connection (active, new_connection);
+
+ if (!_internal_activate_generic (self, active, &local)) {
error = local;
+ goto fail;
}
+ nm_settings_connection_update (new_connection,
+ NULL,
+ persist,
+ NM_SETTINGS_CONNECTION_COMMIT_REASON_USER_ACTION | NM_SETTINGS_CONNECTION_COMMIT_REASON_ID_CHANGED,
+ "add-and-activate",
+ NULL);
+
+ g_dbus_method_invocation_return_value (context,
+ g_variant_new ("(oo)",
+ nm_dbus_object_get_path (NM_DBUS_OBJECT (new_connection)),
+ nm_dbus_object_get_path (NM_DBUS_OBJECT (active))));
+
+ nm_audit_log_connection_op (NM_AUDIT_OP_CONN_ADD_ACTIVATE,
+ nm_active_connection_get_settings_connection (active),
+ TRUE,
+ NULL,
+ nm_active_connection_get_subject (active),
+ NULL);
+ return;
+
+fail:
nm_assert (error);
nm_active_connection_set_state_fail (active,