[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] Avoid an type-punned pointer aliasing pbm



Anmother fix for a warning which I didn't commited yet:

commit 3109546b28b5fc55bf451e62cdb80908cf025ff8
Author: Daniel Veillard <veillard redhat com>
Date:   Tue Dec 8 11:14:55 2009 +0100

    Avoid an type-punned pointer aliasing pbm
    
    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

diff --git a/src/util/network.c b/src/util/network.c
index aaea436..9b9b848 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -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);

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]