diff options
author | Thomas Haller <thaller@redhat.com> | 2019-03-04 15:50:52 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-03-05 09:53:21 +0100 |
commit | be107c75c9eca0f306e79e1e15355166a0db44bd (patch) | |
tree | f11f16e2db522322085dcb4c7df5b07771781ec7 /src | |
parent | d943ea415fda8df02a32726e7aff377c4e4b911f (diff) | |
download | NetworkManager-be107c75c9eca0f306e79e1e15355166a0db44bd.tar.gz |
core: accept %NULL as source argument for nm_utils_ipx_address_clear_host_address()
Just for convenience.
Diffstat (limited to 'src')
-rw-r--r-- | src/NetworkManagerUtils.c | 4 | ||||
-rw-r--r-- | src/nm-core-utils.c | 10 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c index 0fac5eff25..4819846ddb 100644 --- a/src/NetworkManagerUtils.c +++ b/src/NetworkManagerUtils.c @@ -404,8 +404,8 @@ route_compare (NMIPRoute *route1, NMIPRoute *route2, gint64 default_metric) nm_assert_not_reached (); if (!inet_pton (family, nm_ip_route_get_dest (route2), &a2)) nm_assert_not_reached (); - nm_utils_ipx_address_clear_host_address (family, &a1, &a1, plen); - nm_utils_ipx_address_clear_host_address (family, &a2, &a2, plen); + nm_utils_ipx_address_clear_host_address (family, &a1, NULL, plen); + nm_utils_ipx_address_clear_host_address (family, &a2, NULL, plen); NM_CMP_DIRECT_MEMCMP (&a1, &a2, nm_utils_addr_family_to_size (family)); return 0; diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c index 809e98a10c..b851f0a254 100644 --- a/src/nm-core-utils.c +++ b/src/nm-core-utils.c @@ -244,16 +244,20 @@ nm_ethernet_address_is_valid (gconstpointer addr, gssize len) gconstpointer nm_utils_ipx_address_clear_host_address (int family, gpointer dst, gconstpointer src, guint8 plen) { - g_return_val_if_fail (src, NULL); g_return_val_if_fail (dst, NULL); switch (family) { case AF_INET: g_return_val_if_fail (plen <= 32, NULL); + + if (!src) { + /* allow "self-assignment", by specifying %NULL as source. */ + src = dst; + } + *((guint32 *) dst) = nm_utils_ip4_address_clear_host_address (*((guint32 *) src), plen); break; case AF_INET6: - g_return_val_if_fail (plen <= 128, NULL); nm_utils_ip6_address_clear_host_address (dst, src, plen); break; default: @@ -4017,7 +4021,7 @@ nm_utils_get_reverse_dns_domains_ip6 (const struct in6_addr *ip, guint8 plen, GP return; memcpy (&addr, ip, sizeof (struct in6_addr)); - nm_utils_ip6_address_clear_host_address (&addr, &addr, plen); + nm_utils_ip6_address_clear_host_address (&addr, NULL, plen); /* Number of nibbles to include in domains */ nibbles = (plen - 1) / 4 + 1; |