mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-09-06 17:14:02 +00:00
core: assert for valid blocked reasons in autoconnect code
We only have a few blocked reasons. Some of them can be only set on the devcon data, and some only on the settings connection. Assert that we don't mix that up.
This commit is contained in:
parent
2e3fabae50
commit
fc624b8de8
|
@ -1252,7 +1252,7 @@ _autoconnect_retries_initial(NMSettingsConnection *sett_conn)
|
|||
if (retries == -1)
|
||||
retries = nm_config_data_get_autoconnect_retries_default(NM_CONFIG_GET_DATA);
|
||||
|
||||
nm_assert(retries >= 0 && ((guint) retries) <= ((guint) G_MAXINT32));
|
||||
nm_assert(retries >= 0 && retries <= G_MAXINT32);
|
||||
|
||||
if (retries == 0)
|
||||
return NM_AUTOCONNECT_RETRIES_FOREVER;
|
||||
|
@ -1401,16 +1401,15 @@ nm_manager_devcon_autoconnect_reset_reconnect_all(NMManager *self,
|
|||
/* we reset the tries-count and any blocked-reason */
|
||||
nm_manager_devcon_autoconnect_retries_reset(self, NULL, sett_conn);
|
||||
|
||||
/* if there is a device and we changed the state, then something changed. */
|
||||
if (device
|
||||
&& nm_manager_devcon_autoconnect_blocked_reason_set(
|
||||
self,
|
||||
device,
|
||||
sett_conn,
|
||||
NM_SETTINGS_AUTOCONNECT_BLOCKED_REASON_FAILED
|
||||
| NM_SETTINGS_AUTOCONNECT_BLOCKED_REASON_USER_REQUEST,
|
||||
FALSE))
|
||||
changed = TRUE;
|
||||
if (device) {
|
||||
if (nm_manager_devcon_autoconnect_blocked_reason_set(
|
||||
self,
|
||||
device,
|
||||
sett_conn,
|
||||
NM_SETTINGS_AUTOCONNECT_BLOCKED_REASON_FAILED,
|
||||
FALSE))
|
||||
changed = TRUE;
|
||||
}
|
||||
|
||||
/* we remove all the blocked reason from the connection, if something
|
||||
* happened, then it means the status changed */
|
||||
|
@ -1487,8 +1486,9 @@ nm_manager_devcon_autoconnect_blocked_reason_set(NMManager
|
|||
gboolean changed = FALSE;
|
||||
char buf[100];
|
||||
|
||||
nm_assert(value);
|
||||
nm_assert(sett_conn);
|
||||
nm_assert(NM_IS_SETTINGS_CONNECTION(sett_conn));
|
||||
nm_assert(value != NM_SETTINGS_AUTOCONNECT_BLOCKED_REASON_NONE);
|
||||
nm_assert(!NM_FLAGS_ANY(value, ~(NM_SETTINGS_AUTOCONNECT_BLOCKED_REASON_FAILED)));
|
||||
|
||||
if (device) {
|
||||
data = _devcon_lookup_data(self, device, sett_conn, TRUE);
|
||||
|
|
|
@ -2158,7 +2158,7 @@ device_state_changed(NMDevice *device,
|
|||
priv->manager,
|
||||
device,
|
||||
sett_conn,
|
||||
NM_SETTINGS_AUTOCONNECT_BLOCKED_REASON_ALL,
|
||||
NM_SETTINGS_AUTOCONNECT_BLOCKED_REASON_FAILED,
|
||||
FALSE);
|
||||
break;
|
||||
case NM_DEVICE_STATE_SECONDARIES:
|
||||
|
|
|
@ -2526,7 +2526,10 @@ nm_settings_connection_autoconnect_blocked_reason_set(NMSettingsConnection
|
|||
char buf1[100];
|
||||
char buf2[100];
|
||||
|
||||
nm_assert(reason);
|
||||
nm_assert(reason != NM_SETTINGS_AUTOCONNECT_BLOCKED_REASON_NONE);
|
||||
nm_assert(!NM_FLAGS_ANY(reason,
|
||||
~(NM_SETTINGS_AUTOCONNECT_BLOCKED_REASON_USER_REQUEST
|
||||
| NM_SETTINGS_AUTOCONNECT_BLOCKED_REASON_NO_SECRETS)));
|
||||
|
||||
v = priv->autoconnect_blocked_reason;
|
||||
v = NM_FLAGS_ASSIGN(v, reason, set);
|
||||
|
|
Loading…
Reference in a new issue