summaryrefslogtreecommitdiff
path: root/libnm-core
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-10-04 18:46:09 +0200
committerThomas Haller <thaller@redhat.com>2016-10-05 14:46:18 +0200
commite2c71c82e7e8bc87b3f1c820adacf3595dc18656 (patch)
tree98143adae0af4cbfcb282a0c435d2546676b9eb1 /libnm-core
parent29b576bd70bf169e20ca4e6d2b05075957876de9 (diff)
downloadNetworkManager-e2c71c82e7e8bc87b3f1c820adacf3595dc18656.tar.gz
libnm: cleanup error paths in _nm_connection_verify()
Diffstat (limited to 'libnm-core')
-rw-r--r--libnm-core/nm-connection.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c
index 9e9ab930ef..f7ebe6418b 100644
--- a/libnm-core/nm-connection.c
+++ b/libnm-core/nm-connection.c
@@ -989,8 +989,7 @@ _nm_connection_verify (NMConnection *connection, GError **error)
GHashTableIter iter;
gpointer value;
GSList *all_settings = NULL, *setting_i;
- NMSettingVerifyResult success = NM_SETTING_VERIFY_ERROR;
- GError *normalizable_error = NULL;
+ gs_free_error GError *normalizable_error = NULL;
NMSettingVerifyResult normalizable_error_type = NM_SETTING_VERIFY_SUCCESS;
g_return_val_if_fail (NM_IS_CONNECTION (connection), NM_SETTING_VERIFY_ERROR);
@@ -1006,7 +1005,7 @@ _nm_connection_verify (NMConnection *connection, GError **error)
NM_CONNECTION_ERROR_MISSING_SETTING,
_("setting not found"));
g_prefix_error (error, "%s: ", NM_SETTING_CONNECTION_SETTING_NAME);
- goto EXIT;
+ return NM_SETTING_VERIFY_ERROR;
}
/* Build up the list of settings */
@@ -1051,8 +1050,8 @@ _nm_connection_verify (NMConnection *connection, GError **error)
} else if (verify_result != NM_SETTING_VERIFY_SUCCESS) {
g_propagate_error (error, verify_error);
g_slist_free (all_settings);
- g_return_val_if_fail (verify_result == NM_SETTING_VERIFY_ERROR, success);
- goto EXIT;
+ g_return_val_if_fail (verify_result == NM_SETTING_VERIFY_ERROR, NM_SETTING_VERIFY_ERROR);
+ return NM_SETTING_VERIFY_ERROR;
}
g_clear_error (&verify_error);
}
@@ -1062,26 +1061,32 @@ _nm_connection_verify (NMConnection *connection, GError **error)
s_ip6 = nm_connection_get_setting_ip6_config (connection);
if (nm_setting_connection_get_master (s_con)) {
- if ((normalizable_error_type == NM_SETTING_VERIFY_SUCCESS ||
- (normalizable_error_type == NM_SETTING_VERIFY_NORMALIZABLE)) && (s_ip4 || s_ip6)) {
+ if ( NM_IN_SET (normalizable_error_type, NM_SETTING_VERIFY_SUCCESS,
+ NM_SETTING_VERIFY_NORMALIZABLE)
+ && (s_ip4 || s_ip6)) {
g_clear_error (&normalizable_error);
g_set_error_literal (&normalizable_error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_SETTING,
_("setting not allowed in slave connection"));
g_prefix_error (&normalizable_error, "%s: ",
- s_ip4 ? NM_SETTING_IP4_CONFIG_SETTING_NAME : NM_SETTING_IP6_CONFIG_SETTING_NAME);
+ s_ip4
+ ? NM_SETTING_IP4_CONFIG_SETTING_NAME
+ : NM_SETTING_IP6_CONFIG_SETTING_NAME);
/* having a slave with IP config *was* and is a verify() error. */
normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
}
} else {
- if (normalizable_error_type == NM_SETTING_VERIFY_SUCCESS && (!s_ip4 || !s_ip6)) {
+ if ( NM_IN_SET (normalizable_error_type, NM_SETTING_VERIFY_SUCCESS)
+ && (!s_ip4 || !s_ip6)) {
g_set_error_literal (&normalizable_error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_MISSING_SETTING,
_("setting is required for non-slave connections"));
g_prefix_error (&normalizable_error, "%s: ",
- !s_ip4 ? NM_SETTING_IP4_CONFIG_SETTING_NAME : NM_SETTING_IP6_CONFIG_SETTING_NAME);
+ !s_ip4
+ ? NM_SETTING_IP4_CONFIG_SETTING_NAME
+ : NM_SETTING_IP6_CONFIG_SETTING_NAME);
/* having a master without IP config was not a verify() error, accept
* it for backward compatibility. */
normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE;
@@ -1091,13 +1096,10 @@ _nm_connection_verify (NMConnection *connection, GError **error)
if (normalizable_error_type != NM_SETTING_VERIFY_SUCCESS) {
g_propagate_error (error, normalizable_error);
normalizable_error = NULL;
- success = normalizable_error_type;
- } else
- success = NM_SETTING_VERIFY_SUCCESS;
+ return normalizable_error_type;
+ }
-EXIT:
- g_clear_error (&normalizable_error);
- return success;
+ return NM_SETTING_VERIFY_SUCCESS;
}
/**