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 <[email protected]> Signed-off-by: Ben Pfaff <[email protected]> --- include/sparse/netinet/in.h | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/include/sparse/netinet/in.h b/include/sparse/netinet/in.h index eea41bd7f672..21deceb28d41 100644 --- a/include/sparse/netinet/in.h +++ b/include/sparse/netinet/in.h @@ -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 -- 2.16.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
