build: Try to work around strict aliasing rules on Ubuntu 10.04
authorAndrew Bartlett <abartlet@samba.org>
Thu, 2 Jun 2016 21:23:12 +0000 (09:23 +1200)
committerJeremy Allison <jra@samba.org>
Wed, 8 Jun 2016 02:53:13 +0000 (04:53 +0200)
We get cc1: warnings being treated as errors
../lib/util/util_net.c: In function get_socket_port:
../lib/util/util_net.c:921: error: dereferencing pointer sa.106 does break strict-aliasing rules
../lib/util/util_net.c:921: note: initialized from here
../lib/util/util_net.c:925: error: dereferencing pointer sa.107 does break strict-aliasing rules
../lib/util/util_net.c:925: note: initialized from here

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
lib/util/util_net.c

index e5b33aa0a7e5b51d8eb9087f3539cfa6625b25eb..cb238adcf5d89dbe29e65b3d9418663301f6659e 100644 (file)
@@ -918,11 +918,13 @@ int get_socket_port(int fd)
 
 #if defined(HAVE_IPV6)
        if (sa.ss_family == AF_INET6) {
-               return ntohs(((struct sockaddr_in6 *)&sa)->sin6_port);
+               struct sockaddr_in6 *sa_in6 = (struct sockaddr_in6 *)&sa;
+               return ntohs(sa_in6->sin6_port);
        }
 #endif
        if (sa.ss_family == AF_INET) {
-               return ntohs(((struct sockaddr_in *)&sa)->sin_port);
+               struct sockaddr_in *sa_in = (struct sockaddr_in *)&sa;
+               return ntohs(sa_in->sin_port);
        }
        return -1;
 }