From 9934be52cd453202248cb5f7f7dadbe05a2412de Mon Sep 17 00:00:00 2001 From: Fernando Fernandez Mancera Date: Fri, 27 Jan 2023 11:22:43 +0100 Subject: [PATCH] device: use NMUnmanFlagOp enum members instead of literals Replace TRUE or FALSE for their NMUnmanFlagOp enum member. It is more intuitive for newcomers so they can understand what is being set without looking at the values or function logic. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1516 --- src/core/devices/nm-device.c | 9 ++++++--- src/core/devices/nm-device.h | 6 +++--- src/core/nm-checkpoint.c | 4 ++-- src/core/nm-manager.c | 14 +++++++------- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 93399cafb2..248f2364f5 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -6811,7 +6811,10 @@ device_link_changed(gpointer user_data) * sync state transition. */ nm_device_queue_recheck_assume(self); - nm_device_set_unmanaged_by_flags_queue(self, NM_UNMANAGED_PLATFORM_INIT, FALSE, reason); + nm_device_set_unmanaged_by_flags_queue(self, + NM_UNMANAGED_PLATFORM_INIT, + NM_UNMAN_FLAG_OP_SET_MANAGED, + reason); } _dev_unmanaged_check_external_down(self, FALSE, FALSE); @@ -7867,7 +7870,7 @@ nm_device_master_add_slave(NMDevice *self, NMDevice *slave, gboolean configure) g_warn_if_fail(!NM_FLAGS_HAS(slave_priv->unmanaged_mask, NM_UNMANAGED_IS_SLAVE)); nm_device_set_unmanaged_by_flags(slave, NM_UNMANAGED_IS_SLAVE, - FALSE, + NM_UNMAN_FLAG_OP_SET_MANAGED, NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); changed = TRUE; } else @@ -14687,7 +14690,7 @@ nm_device_set_unmanaged_by_quitting(NMDevice *self) nm_device_set_unmanaged_by_flags(self, NM_UNMANAGED_QUITTING, - TRUE, + NM_UNMAN_FLAG_OP_SET_UNMANAGED, need_deactivate ? NM_DEVICE_STATE_REASON_REMOVED : NM_DEVICE_STATE_REASON_NOW_UNMANAGED); } diff --git a/src/core/devices/nm-device.h b/src/core/devices/nm-device.h index f54457d12e..fd6b9d93f8 100644 --- a/src/core/devices/nm-device.h +++ b/src/core/devices/nm-device.h @@ -608,9 +608,9 @@ typedef enum { } NMUnmanagedFlags; typedef enum { - NM_UNMAN_FLAG_OP_SET_MANAGED = FALSE, - NM_UNMAN_FLAG_OP_SET_UNMANAGED = TRUE, - NM_UNMAN_FLAG_OP_FORGET = 2, + NM_UNMAN_FLAG_OP_SET_MANAGED = 0, + NM_UNMAN_FLAG_OP_SET_UNMANAGED, + NM_UNMAN_FLAG_OP_FORGET, } NMUnmanFlagOp; const char *nm_unmanaged_flags2str(NMUnmanagedFlags flags, char *buf, gsize len); diff --git a/src/core/nm-checkpoint.c b/src/core/nm-checkpoint.c index cd0e17fa87..0beeb4ba26 100644 --- a/src/core/nm-checkpoint.c +++ b/src/core/nm-checkpoint.c @@ -368,7 +368,7 @@ nm_checkpoint_rollback(NMCheckpoint *self) _LOGD("rollback: device was not realized, unmanage it"); nm_device_set_unmanaged_by_flags_queue(device, NM_UNMANAGED_USER_EXPLICIT, - TRUE, + NM_UNMAN_FLAG_OP_SET_UNMANAGED, NM_DEVICE_STATE_REASON_NOW_UNMANAGED); goto next_dev; } @@ -402,7 +402,7 @@ nm_checkpoint_rollback(NMCheckpoint *self) _LOGD("rollback: explicitly unmanage device"); nm_device_set_unmanaged_by_flags_queue(device, NM_UNMANAGED_USER_EXPLICIT, - TRUE, + NM_UNMAN_FLAG_OP_SET_UNMANAGED, NM_DEVICE_STATE_REASON_NOW_UNMANAGED); } goto next_dev; diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index 665472941f..9d444e45f3 100644 --- a/src/core/nm-manager.c +++ b/src/core/nm-manager.c @@ -1804,7 +1804,7 @@ remove_device(NMManager *self, NMDevice *device, gboolean quitting) nm_device_sys_iface_state_set(device, NM_DEVICE_SYS_IFACE_STATE_REMOVED); nm_device_set_unmanaged_by_flags(device, NM_UNMANAGED_PLATFORM_INIT, - TRUE, + NM_UNMAN_FLAG_OP_SET_UNMANAGED, NM_DEVICE_STATE_REASON_REMOVED); } } @@ -4942,12 +4942,12 @@ unmanaged_to_disconnected(NMDevice *device) * and force the device to be managed. */ nm_device_set_unmanaged_by_flags(device, NM_UNMANAGED_PLATFORM_INIT, - FALSE, + NM_UNMAN_FLAG_OP_SET_MANAGED, NM_DEVICE_STATE_REASON_USER_REQUESTED); nm_device_set_unmanaged_by_flags(device, NM_UNMANAGED_USER_EXPLICIT, - FALSE, + NM_UNMAN_FLAG_OP_SET_MANAGED, NM_DEVICE_STATE_REASON_USER_REQUESTED); if (!nm_device_get_managed(device, FALSE)) { @@ -6500,7 +6500,7 @@ device_sleep_cb(NMDevice *device, GParamSpec *pspec, NMManager *self) _LOGD(LOGD_SUSPEND, "sleep: unmanaging device %s", nm_device_get_ip_iface(device)); nm_device_set_unmanaged_by_flags_queue(device, NM_UNMANAGED_SLEEPING, - TRUE, + NM_UNMAN_FLAG_OP_SET_UNMANAGED, NM_DEVICE_STATE_REASON_SLEEPING); break; case NM_DEVICE_STATE_UNMANAGED: @@ -6562,7 +6562,7 @@ do_sleep_wake(NMManager *self, gboolean sleeping_changed) } else { nm_device_set_unmanaged_by_flags(device, NM_UNMANAGED_SLEEPING, - TRUE, + NM_UNMAN_FLAG_OP_SET_UNMANAGED, NM_DEVICE_STATE_REASON_SLEEPING); } } @@ -6582,7 +6582,7 @@ do_sleep_wake(NMManager *self, gboolean sleeping_changed) if (device_is_wake_on_lan(priv->platform, device)) nm_device_set_unmanaged_by_flags(device, NM_UNMANAGED_SLEEPING, - TRUE, + NM_UNMAN_FLAG_OP_SET_UNMANAGED, NM_DEVICE_STATE_REASON_SLEEPING); /* Check if the device is unmanaged but the state transition is still pending. @@ -6638,7 +6638,7 @@ do_sleep_wake(NMManager *self, gboolean sleeping_changed) nm_device_set_unmanaged_by_flags(device, NM_UNMANAGED_SLEEPING, - FALSE, + NM_UNMAN_FLAG_OP_SET_MANAGED, NM_DEVICE_STATE_REASON_NOW_MANAGED); }