diff options
author | Thomas Haller <thaller@redhat.com> | 2022-02-22 10:08:30 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-03-13 12:02:09 +0100 |
commit | a566fd8cf40fb3c6ef18bdf929a9983d64020363 (patch) | |
tree | 1cb78bd05f14997b4f87e9b3d91cd231a3cef86b | |
parent | 53406e721da77175a970534b0f6c28405a0602e9 (diff) | |
download | NetworkManager-a566fd8cf40fb3c6ef18bdf929a9983d64020363.tar.gz |
core/device: use c_list_for_each_entry() for interating of slaves list
This convenience macro is just shorter, resulting in more(?) readable
code and less clutter.
-rw-r--r-- | src/core/devices/nm-device.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index b96f8e7294..17acfabb3e 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -5878,11 +5878,9 @@ static SlaveInfo * find_slave_info(NMDevice *self, NMDevice *slave) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - CList *iter; SlaveInfo *info; - c_list_for_each (iter, &priv->slaves) { - info = c_list_entry(iter, SlaveInfo, lst_slave); + c_list_for_each_entry (info, &priv->slaves, lst_slave) { if (info->slave == slave) return info; } @@ -7627,14 +7625,12 @@ nm_device_master_check_slave_physical_port(NMDevice *self, NMDevice *slave, NMLo NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); const char *slave_physical_port_id, *existing_physical_port_id; SlaveInfo *info; - CList *iter; slave_physical_port_id = nm_device_get_physical_port_id(slave); if (!slave_physical_port_id) return; - c_list_for_each (iter, &priv->slaves) { - info = c_list_entry(iter, SlaveInfo, lst_slave); + c_list_for_each_entry (info, &priv->slaves, lst_slave) { if (info->slave == slave) continue; @@ -7660,7 +7656,8 @@ nm_device_master_release_slaves(NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMDeviceStateReason reason; - CList *iter, *safe; + SlaveInfo *info; + SlaveInfo *safe; /* Don't release the slaves if this connection doesn't belong to NM. */ if (nm_device_sys_iface_state_is_external(self)) @@ -7670,9 +7667,7 @@ nm_device_master_release_slaves(NMDevice *self) if (priv->state == NM_DEVICE_STATE_FAILED) reason = NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED; - c_list_for_each_safe (iter, safe, &priv->slaves) { - SlaveInfo *info = c_list_entry(iter, SlaveInfo, lst_slave); - + c_list_for_each_entry_safe (info, safe, &priv->slaves, lst_slave) { if (priv->activation_state_preserve_external_ports && nm_device_sys_iface_state_is_external(info->slave)) { _LOGT(LOGD_DEVICE, @@ -9437,7 +9432,7 @@ activate_stage2_device_config(NMDevice *self) NMActStageReturn ret; NMSettingWired *s_wired; gboolean no_firmware = FALSE; - CList *iter; + SlaveInfo *info; NMTernary accept_all_mac_addresses; nm_device_state_changed(self, NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_REASON_NONE); @@ -9484,8 +9479,7 @@ activate_stage2_device_config(NMDevice *self) } /* If we have slaves that aren't yet enslaved, do that now */ - c_list_for_each (iter, &priv->slaves) { - SlaveInfo *info = c_list_entry(iter, SlaveInfo, lst_slave); + c_list_for_each_entry (info, &priv->slaves, lst_slave) { NMDeviceState slave_state = nm_device_get_state(info->slave); if (slave_state == NM_DEVICE_STATE_IP_CONFIG) @@ -10413,14 +10407,12 @@ have_any_ready_slaves(NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); SlaveInfo *info; - CList *iter; /* Any enslaved slave is "ready" in the generic case as it's - * at least >= NM_DEVCIE_STATE_IP_CONFIG and has had Layer 2 + * at least >= NM_DEVICE_STATE_IP_CONFIG and has had Layer 2 * properties set up. */ - c_list_for_each (iter, &priv->slaves) { - info = c_list_entry(iter, SlaveInfo, lst_slave); + c_list_for_each_entry (info, &priv->slaves, lst_slave) { if (NM_DEVICE_GET_PRIVATE(info->slave)->is_enslaved) return TRUE; } |