[Olsr-dev] [PATCH v1 11/14] p2pd: fix GCC 6 warnings

Ferry Huberts (spam-protected)
Wed Feb 24 00:46:20 CET 2016


From: Ferry Huberts <(spam-protected)>

src/NetworkInterfaces.c: In function ‘CreateInterface’:
src/NetworkInterfaces.c:247:50: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
       newIf->intAddr.v4 = ((struct sockaddr_in *) ARM_NOWARN_ALIGN(&ifr.ifr_addr))->sin_addr;
                                                  ^
src/NetworkInterfaces.c:260:52: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
       newIf->broadAddr.v4 = ((struct sockaddr_in *) ARM_NOWARN_ALIGN(&ifr.ifr_broadaddr))->sin_addr;
                                                    ^
src/NetworkInterfaces.c: In function ‘CreateNonOlsrNetworkInterfaces’:
src/NetworkInterfaces.c:368:40: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
     ipAddr.v4 = ((struct sockaddr_in *) ARM_NOWARN_ALIGN(&ifr->ifr_addr))->sin_addr;
                                        ^

Signed-off-by: Ferry Huberts <(spam-protected)>
---
 lib/p2pd/src/NetworkInterfaces.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/p2pd/src/NetworkInterfaces.c b/lib/p2pd/src/NetworkInterfaces.c
index 8a015d0..77c13a5 100644
--- a/lib/p2pd/src/NetworkInterfaces.c
+++ b/lib/p2pd/src/NetworkInterfaces.c
@@ -244,7 +244,8 @@ CreateInterface(const char *ifName, struct interface_olsr *olsrIntf)
       newIf->intAddr.v4.s_addr = inet_addr("0.0.0.0");
     } else {
       /* Downcast to correct sockaddr subtype */
-      newIf->intAddr.v4 = ((struct sockaddr_in *) ARM_NOWARN_ALIGN(&ifr.ifr_addr))->sin_addr;
+      struct sockaddr* ifra = &ifr.ifr_addr;
+      newIf->intAddr.v4 = ((struct sockaddr_in *) ARM_NOWARN_ALIGN(ifra))->sin_addr;
     }
 
     /* For a non-OLSR interface, retrieve the IP broadcast address ourselves */
@@ -257,7 +258,8 @@ CreateInterface(const char *ifName, struct interface_olsr *olsrIntf)
       newIf->broadAddr.v4.s_addr = inet_addr("0.0.0.0");
     } else {
       /* Downcast to correct sockaddr subtype */
-      newIf->broadAddr.v4 = ((struct sockaddr_in *) ARM_NOWARN_ALIGN(&ifr.ifr_broadaddr))->sin_addr;
+      struct sockaddr* ifrb = &ifr.ifr_broadaddr;
+      newIf->broadAddr.v4 = ((struct sockaddr_in *) ARM_NOWARN_ALIGN(ifrb))->sin_addr;
     }
   }
 
@@ -365,7 +367,10 @@ CreateNonOlsrNetworkInterfaces(struct interface_olsr *skipThisIntf)
     //}
 
     /* ...find the OLSR interface structure, if any */
-    ipAddr.v4 = ((struct sockaddr_in *) ARM_NOWARN_ALIGN(&ifr->ifr_addr))->sin_addr;
+    {
+      struct sockaddr* ifra = &ifr->ifr_addr;
+      ipAddr.v4 = ((struct sockaddr_in *) ARM_NOWARN_ALIGN(ifra))->sin_addr;
+    }
     olsrIntf = if_ifwithaddr(&ipAddr);
 
     if (skipThisIntf != NULL && olsrIntf == skipThisIntf) {
-- 
2.5.0




More information about the Olsr-dev mailing list