mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-15 20:45:32 +00:00
libnm: cleanup error paths in _nm_connection_verify()
This commit is contained in:
parent
29b576bd70
commit
e2c71c82e7
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue