]> git.proxmox.com Git - mirror_ovs.git/commitdiff
sparse: Make IN6_IS_ADDR_MC_LINKLOCAL and IN6_ARE_ADDR_EQUAL pickier.
authorBen Pfaff <blp@ovn.org>
Tue, 10 Jul 2018 16:27:18 +0000 (09:27 -0700)
committerBen Pfaff <blp@ovn.org>
Wed, 11 Jul 2018 15:28:33 +0000 (08:28 -0700)
On GNU systems these macros work with arbitrary pointers, but the relevant
standards only require IN6_IS_ADDR_MC_LINKLOCAL to work with in6_addr (and
don't specify IN6_ARE_ADDR_EQUAL at all).  Make the "sparse"
implementations correspondingly pickier so that we catch any introduced
problems more quickly.

CC: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Aaron Conole <aconole@redhat.com>
include/sparse/netinet/in.h

index eea41bd7f672eaa4a55466da3786210484c3bb89..21deceb28d41e9bdaba6e98cce99975cb75a9223 100644 (file)
@@ -124,14 +124,25 @@ struct sockaddr_in6 {
      (X)->s6_addr[11] == 0xff)
 
 #define IN6_IS_ADDR_MC_LINKLOCAL(a)                 \
-    (((const uint8_t *) (a))[0] == 0xff &&          \
-     (((const uint8_t *) (a))[1] & 0xf) == 0x2)
-
-# define IN6_ARE_ADDR_EQUAL(a,b)                                          \
-    ((((const uint32_t *) (a))[0] == ((const uint32_t *) (b))[0]) &&      \
-     (((const uint32_t *) (a))[1] == ((const uint32_t *) (b))[1]) &&      \
-     (((const uint32_t *) (a))[2] == ((const uint32_t *) (b))[2]) &&      \
-     (((const uint32_t *) (a))[3] == ((const uint32_t *) (b))[3]))
+    ((a)->s6_addr[0] == 0xff && ((a)->s6_addr[1] & 0xf) == 0x2)
+
+# define IN6_ARE_ADDR_EQUAL(a, b)               \
+    ((a)->s6_addr[0] == (b)->s6_addr[0] &&      \
+     (a)->s6_addr[1] == (b)->s6_addr[1] &&      \
+     (a)->s6_addr[2] == (b)->s6_addr[2] &&      \
+     (a)->s6_addr[3] == (b)->s6_addr[3] &&      \
+     (a)->s6_addr[4] == (b)->s6_addr[4] &&      \
+     (a)->s6_addr[5] == (b)->s6_addr[5] &&      \
+     (a)->s6_addr[6] == (b)->s6_addr[6] &&      \
+     (a)->s6_addr[7] == (b)->s6_addr[7] &&      \
+     (a)->s6_addr[8] == (b)->s6_addr[8] &&      \
+     (a)->s6_addr[9] == (b)->s6_addr[9] &&      \
+     (a)->s6_addr[10] == (b)->s6_addr[10] &&    \
+     (a)->s6_addr[11] == (b)->s6_addr[11] &&    \
+     (a)->s6_addr[12] == (b)->s6_addr[12] &&    \
+     (a)->s6_addr[13] == (b)->s6_addr[13] &&    \
+     (a)->s6_addr[14] == (b)->s6_addr[14] &&    \
+     (a)->s6_addr[15] == (b)->s6_addr[15])
 
 #define INET_ADDRSTRLEN 16
 #define INET6_ADDRSTRLEN 46