From 46c5a48ff2d46f60f1cf71ca55408e1aab4211b7 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 4 May 2010 12:45:36 -0700 Subject: [PATCH] ip6: use IN6_ARE_ADDR_EQUAL not memcmp --- src/ip6-manager/nm-ip6-manager.c | 10 +++++----- src/nm-ip6-config.c | 7 +++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/ip6-manager/nm-ip6-manager.c b/src/ip6-manager/nm-ip6-manager.c index 333638adb3..be22e6465b 100644 --- a/src/ip6-manager/nm-ip6-manager.c +++ b/src/ip6-manager/nm-ip6-manager.c @@ -652,7 +652,7 @@ process_nduseropt (NMIP6Manager *manager, struct nl_msg *msg) for (i = 0; i < servers->len; i++) { sa = &(g_array_index (servers, NMIP6RDNSS, i)); sb = &(g_array_index (device->rdnss_servers, NMIP6RDNSS, i)); - if (memcmp (&sa->addr, &sb->addr, sizeof (struct in6_addr)) != 0) { + if (IN6_ARE_ADDR_EQUAL (&sa->addr, &sb->addr) == FALSE) { changed = TRUE; break; } @@ -965,11 +965,11 @@ nm_ip6_manager_get_ip6_config (NMIP6Manager *manager, int ifindex) continue; } - /* Also ignore routes where the destination and gateway are the same, - * which apparently get added by the kernel but return -EINVAL when - * we try to add them via netlink. + /* Also ignore link-local routes where the destination and gateway are + * the same, which apparently get added by the kernel but return -EINVAL + * when we try to add them via netlink. */ - if (gateway && !memcmp (dest, gateway, sizeof (struct in6_addr))) + if (gateway && IN6_ARE_ADDR_EQUAL (dest, gateway)) continue; ip6route = nm_ip6_route_new (); diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index 89b8c1a665..2fea38f331 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -203,9 +203,8 @@ void nm_ip6_config_add_nameserver (NMIP6Config *config, const struct in6_addr *n /* No dupes */ nameservers = (struct in6_addr *)priv->nameservers->data; - for (i = 0; i < priv->nameservers->len; i++) { - g_return_if_fail (memcmp (nameserver, &nameservers[i], sizeof (struct in6_addr)) != 0); - } + for (i = 0; i < priv->nameservers->len; i++) + g_return_if_fail (IN6_ARE_ADDR_EQUAL (nameserver, &nameservers[i]) == FALSE); g_array_append_val (priv->nameservers, *nameserver); } @@ -572,7 +571,7 @@ addr_array_compare (GArray *a, GArray *b) addrs_b = (struct in6_addr *)b->data; for (i = 0; i < a->len; i++) { for (j = 0, found = FALSE; j < b->len; j++) { - if (memcmp (&addrs_a[i], &addrs_b[j], sizeof (struct in6_addr)) == 0) { + if (IN6_ARE_ADDR_EQUAL (&addrs_a[i], &addrs_b[j])) { found = TRUE; break; }