pud: fix GCC 6 warnings
authorFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 23 Feb 2016 18:51:50 +0000 (19:51 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 25 Feb 2016 12:39:33 +0000 (13:39 +0100)
src/netTools.c: In function ‘getIPv4Address’:
src/netTools.c:96:55: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
  return &((struct sockaddr_in *)(void *) &ifr->ifr_addr)->sin_addr;
                                                       ^

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/pud/src/netTools.c

index f4acb7e..7627676 100644 (file)
@@ -93,5 +93,8 @@ struct in_addr * getIPv4Address(const char * ifName, struct ifreq *ifr) {
 
        close(fd);
 
-       return &((struct sockaddr_in *)(void *) &ifr->ifr_addr)->sin_addr;
+       {
+         struct sockaddr* ifra = &ifr->ifr_addr;
+         return &((struct sockaddr_in *)(void *) ifra)->sin_addr;
+       }
 }