]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Avoid an type-punned pointer aliasing pbm
authorDaniel Veillard <veillard@redhat.com>
Tue, 8 Dec 2009 10:14:55 +0000 (11:14 +0100)
committerDaniel Veillard <veillard@redhat.com>
Tue, 8 Dec 2009 14:01:57 +0000 (15:01 +0100)
Fix this warning, there is no need to use an intermediate,
different array pointer.
network.c: In function 'getIPv6Addr':
network.c:50: warning: dereferencing type-punned pointer will break strict-aliasing rules
* src/util/network.c: avoid an intermediary pointer cast

src/util/network.c

index aaea436a140506d6d2fc99fca04f9d04c8a3b880..9b9b848dcef8dc56c6cefeef3194a57a7f04ecbc 100644 (file)
@@ -41,16 +41,13 @@ static int getIPv4Addr(virSocketAddrPtr addr, virIPv4AddrPtr tab) {
 }
 
 static int getIPv6Addr(virSocketAddrPtr addr, virIPv6AddrPtr tab) {
-    virIPv6AddrPtr val;
     int i;
 
     if ((addr == NULL) || (tab == NULL) || (addr->stor.ss_family != AF_INET6))
         return(-1);
 
-    val = (virIPv6AddrPtr) &(addr->inet6.sin6_addr.s6_addr16);
-
     for (i = 0;i < 8;i++) {
-        (*tab)[i] = ntohs((*val)[i]);
+        (*tab)[i] = ntohs(addr->inet6.sin6_addr.s6_addr16[i]);
     }
 
     return(0);