mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 18:50:07 +01:00
manager: convert hwaddr to binary once in find_device_by_permanent_hw_addr()
For comparing MAC addresses, they anyway have to be normalized to binary. Convert it once outside the loop and pass the binary form to nm_utils_hwaddr_matches(). Otherwise, we need to re-convert it every time.
This commit is contained in:
parent
4a705e1a0c
commit
199f2df50f
1 changed files with 4 additions and 2 deletions
|
|
@ -960,16 +960,18 @@ find_device_by_permanent_hw_addr (NMManager *self, const char *hwaddr)
|
|||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
||||
NMDevice *device;
|
||||
const char *device_addr;
|
||||
guint8 hwaddr_bin[NM_UTILS_HWADDR_LEN_MAX];
|
||||
gsize hwaddr_len;
|
||||
|
||||
g_return_val_if_fail (hwaddr != NULL, NULL);
|
||||
|
||||
if (!nm_utils_hwaddr_valid (hwaddr, -1))
|
||||
if (!_nm_utils_hwaddr_aton (hwaddr, hwaddr_bin, sizeof (hwaddr_bin), &hwaddr_len))
|
||||
return NULL;
|
||||
|
||||
c_list_for_each_entry (device, &priv->devices_lst_head, devices_lst) {
|
||||
device_addr = nm_device_get_permanent_hw_address (device);
|
||||
if ( device_addr
|
||||
&& nm_utils_hwaddr_matches (hwaddr, -1, device_addr, -1))
|
||||
&& nm_utils_hwaddr_matches (hwaddr_bin, hwaddr_len, device_addr, -1))
|
||||
return device;
|
||||
}
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue