mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 03:38:09 +02:00
libnm: cleanup error paths in _nm_connection_verify()
This commit is contained in:
parent
29b576bd70
commit
e2c71c82e7
1 changed files with 18 additions and 16 deletions
|
|
@ -989,8 +989,7 @@ _nm_connection_verify (NMConnection *connection, GError **error)
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
gpointer value;
|
gpointer value;
|
||||||
GSList *all_settings = NULL, *setting_i;
|
GSList *all_settings = NULL, *setting_i;
|
||||||
NMSettingVerifyResult success = NM_SETTING_VERIFY_ERROR;
|
gs_free_error GError *normalizable_error = NULL;
|
||||||
GError *normalizable_error = NULL;
|
|
||||||
NMSettingVerifyResult normalizable_error_type = NM_SETTING_VERIFY_SUCCESS;
|
NMSettingVerifyResult normalizable_error_type = NM_SETTING_VERIFY_SUCCESS;
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NM_SETTING_VERIFY_ERROR);
|
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,
|
NM_CONNECTION_ERROR_MISSING_SETTING,
|
||||||
_("setting not found"));
|
_("setting not found"));
|
||||||
g_prefix_error (error, "%s: ", NM_SETTING_CONNECTION_SETTING_NAME);
|
g_prefix_error (error, "%s: ", NM_SETTING_CONNECTION_SETTING_NAME);
|
||||||
goto EXIT;
|
return NM_SETTING_VERIFY_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Build up the list of settings */
|
/* 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) {
|
} else if (verify_result != NM_SETTING_VERIFY_SUCCESS) {
|
||||||
g_propagate_error (error, verify_error);
|
g_propagate_error (error, verify_error);
|
||||||
g_slist_free (all_settings);
|
g_slist_free (all_settings);
|
||||||
g_return_val_if_fail (verify_result == NM_SETTING_VERIFY_ERROR, success);
|
g_return_val_if_fail (verify_result == NM_SETTING_VERIFY_ERROR, NM_SETTING_VERIFY_ERROR);
|
||||||
goto EXIT;
|
return NM_SETTING_VERIFY_ERROR;
|
||||||
}
|
}
|
||||||
g_clear_error (&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);
|
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
||||||
|
|
||||||
if (nm_setting_connection_get_master (s_con)) {
|
if (nm_setting_connection_get_master (s_con)) {
|
||||||
if ((normalizable_error_type == NM_SETTING_VERIFY_SUCCESS ||
|
if ( NM_IN_SET (normalizable_error_type, NM_SETTING_VERIFY_SUCCESS,
|
||||||
(normalizable_error_type == NM_SETTING_VERIFY_NORMALIZABLE)) && (s_ip4 || s_ip6)) {
|
NM_SETTING_VERIFY_NORMALIZABLE)
|
||||||
|
&& (s_ip4 || s_ip6)) {
|
||||||
g_clear_error (&normalizable_error);
|
g_clear_error (&normalizable_error);
|
||||||
g_set_error_literal (&normalizable_error,
|
g_set_error_literal (&normalizable_error,
|
||||||
NM_CONNECTION_ERROR,
|
NM_CONNECTION_ERROR,
|
||||||
NM_CONNECTION_ERROR_INVALID_SETTING,
|
NM_CONNECTION_ERROR_INVALID_SETTING,
|
||||||
_("setting not allowed in slave connection"));
|
_("setting not allowed in slave connection"));
|
||||||
g_prefix_error (&normalizable_error, "%s: ",
|
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. */
|
/* having a slave with IP config *was* and is a verify() error. */
|
||||||
normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
|
normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
|
||||||
}
|
}
|
||||||
} else {
|
} 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,
|
g_set_error_literal (&normalizable_error,
|
||||||
NM_CONNECTION_ERROR,
|
NM_CONNECTION_ERROR,
|
||||||
NM_CONNECTION_ERROR_MISSING_SETTING,
|
NM_CONNECTION_ERROR_MISSING_SETTING,
|
||||||
_("setting is required for non-slave connections"));
|
_("setting is required for non-slave connections"));
|
||||||
g_prefix_error (&normalizable_error, "%s: ",
|
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
|
/* having a master without IP config was not a verify() error, accept
|
||||||
* it for backward compatibility. */
|
* it for backward compatibility. */
|
||||||
normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE;
|
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) {
|
if (normalizable_error_type != NM_SETTING_VERIFY_SUCCESS) {
|
||||||
g_propagate_error (error, normalizable_error);
|
g_propagate_error (error, normalizable_error);
|
||||||
normalizable_error = NULL;
|
normalizable_error = NULL;
|
||||||
success = normalizable_error_type;
|
return normalizable_error_type;
|
||||||
} else
|
}
|
||||||
success = NM_SETTING_VERIFY_SUCCESS;
|
|
||||||
|
|
||||||
EXIT:
|
return NM_SETTING_VERIFY_SUCCESS;
|
||||||
g_clear_error (&normalizable_error);
|
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue