diff options
Diffstat (limited to 'libnm-core')
| -rw-r--r-- | libnm-core/nm-setting-bridge.c | 4 | ||||
| -rw-r--r-- | libnm-core/nm-utils.c | 17 | ||||
| -rw-r--r-- | libnm-core/tests/test-general.c | 10 |
3 files changed, 21 insertions, 10 deletions
diff --git a/libnm-core/nm-setting-bridge.c b/libnm-core/nm-setting-bridge.c index 23856e5c..d79e83ea 100644 --- a/libnm-core/nm-setting-bridge.c +++ b/libnm-core/nm-setting-bridge.c @@ -223,8 +223,8 @@ _nm_bridge_vlan_dup_and_seal (const NMBridgeVlan *vlan) /** * nm_bridge_vlan_get_vid_range: * @vlan: the #NMBridgeVlan - * @vid_start: location to store the VLAN id range start. - * @vid_end: location to store the VLAN id range end + * @vid_start: (out): location to store the VLAN id range start. + * @vid_end: (out): location to store the VLAN id range end * * Gets the VLAN id range. * diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 29b62e2f..8f2b4018 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -4291,14 +4291,15 @@ nm_utils_hwaddr_matches (gconstpointer hwaddr1, gsize l; if (hwaddr1_len == -1) { - g_return_val_if_fail (hwaddr1 != NULL, FALSE); - - if (!hwaddr_aton (hwaddr1, buf1, sizeof (buf1), &l)) { + if (hwaddr1 == NULL) { + hwaddr1_len = 0; + } else if (hwaddr_aton (hwaddr1, buf1, sizeof (buf1), &l)) { + hwaddr1 = buf1; + hwaddr1_len = l; + } else { g_return_val_if_fail ((hwaddr2_len == -1 && hwaddr2) || (hwaddr2_len > 0 && hwaddr2_len <= NM_UTILS_HWADDR_LEN_MAX), FALSE); return FALSE; } - hwaddr1 = buf1; - hwaddr1_len = l; } else { g_return_val_if_fail (hwaddr1_len > 0 && hwaddr1_len <= NM_UTILS_HWADDR_LEN_MAX, FALSE); @@ -4309,9 +4310,9 @@ nm_utils_hwaddr_matches (gconstpointer hwaddr1, } if (hwaddr2_len == -1) { - g_return_val_if_fail (hwaddr2 != NULL, FALSE); - - if (!hwaddr_aton (hwaddr2, buf2, sizeof (buf2), &l)) + if (hwaddr2 == NULL) + l = 0; + else if (!hwaddr_aton (hwaddr2, buf2, sizeof (buf2), &l)) return FALSE; if (l != hwaddr1_len) return FALSE; diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index 601e3edc..13fed902 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -3964,6 +3964,16 @@ test_hwaddr_equal (void) g_assert (nm_utils_hwaddr_matches (null_binary, sizeof (null_binary), null_string, -1)); g_assert (nm_utils_hwaddr_matches (null_binary, sizeof (null_binary), null_binary, sizeof (null_binary))); g_assert (nm_utils_hwaddr_matches (null_binary, sizeof (null_binary), NULL, ETH_ALEN)); + + g_assert (nm_utils_hwaddr_matches (NULL, -1, NULL, -1)); + g_assert (!nm_utils_hwaddr_matches (NULL, -1, string, -1)); + g_assert (!nm_utils_hwaddr_matches (string, -1, NULL, -1)); + g_assert (!nm_utils_hwaddr_matches (NULL, -1, null_string, -1)); + g_assert (!nm_utils_hwaddr_matches (null_string, -1, NULL, -1)); + g_assert (!nm_utils_hwaddr_matches (NULL, -1, binary, sizeof (binary))); + g_assert (!nm_utils_hwaddr_matches (binary, sizeof (binary), NULL, -1)); + g_assert (!nm_utils_hwaddr_matches (NULL, -1, null_binary, sizeof (null_binary))); + g_assert (!nm_utils_hwaddr_matches (null_binary, sizeof (null_binary), NULL, -1)); } static void |