]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[build] Avoid strict-aliasing warnings when building with gcc 4.4
authorMichael Brown <mcb30@etherboot.org>
Tue, 6 Jan 2009 03:19:23 +0000 (19:19 -0800)
committerMichael Brown <mcb30@etherboot.org>
Tue, 6 Jan 2009 03:20:26 +0000 (19:20 -0800)
Conventional usage of the various struct sockaddr_xxx types involves
liberal use of casting, which tends to trigger strict-aliasing
warnings from gcc.  Avoid these now and in future by marking all the
relevant types with __attribute__((may_alias)).

src/include/gpxe/in.h
src/include/gpxe/open.h
src/include/gpxe/resolv.h
src/include/gpxe/socket.h
src/include/gpxe/tcpip.h
src/include/gpxe/udp.h

index 40e4d4073fe5b7a8dd309a4b87fba04e45e7196e..831a6110f0832ddfd4443f1d4df43e28b1fbb9fb 100644 (file)
@@ -71,7 +71,7 @@ struct sockaddr_in {
        char pad[ sizeof ( struct sockaddr ) - sizeof ( sa_family_t )
                                             - sizeof ( uint16_t )
                                             - sizeof ( struct in_addr ) ];
-};
+} __attribute__ (( may_alias ));
 
 /**
  * IPv6 socket address
@@ -87,7 +87,7 @@ struct sockaddr_in6 {
         uint32_t        sin6_flowinfo;  /* Flow number */
         struct in6_addr sin6_addr;      /* 128-bit destination address */
         uint32_t        sin6_scope_id;  /* Scope ID */
-};
+} __attribute__ (( may_alias ));
 
 extern int inet_aton ( const char *cp, struct in_addr *inp );
 extern char * inet_ntoa ( struct in_addr in );
index beab0a1f72cdcded32d9edbffd43463a765eeec1..81d5fc24601089511acbe6e39504b13131cedeac 100644 (file)
@@ -9,10 +9,10 @@
 
 #include <stdarg.h>
 #include <gpxe/tables.h>
+#include <gpxe/socket.h>
 
 struct xfer_interface;
 struct uri;
-struct sockaddr;
 
 /** Location types */
 enum {
index 7c1ee6e20108629c3729da070430a660a7be0bd8..e73c82011ed30ecc52884305b45353a37093fe3e 100644 (file)
@@ -10,8 +10,8 @@
 #include <gpxe/refcnt.h>
 #include <gpxe/interface.h>
 #include <gpxe/tables.h>
+#include <gpxe/socket.h>
 
-struct sockaddr;
 struct resolv_interface;
 
 /** Name resolution interface operations */
index 582de4ef98e6d3071d99be1814b8fc90aa64950c..b683bed65f0e507608f0e94fe1b32c82dabae511 100644 (file)
@@ -94,6 +94,6 @@ struct sockaddr {
         * family.
         */
        char pad[ SA_LEN - sizeof ( sa_family_t ) ];
-};
+} __attribute__ (( may_alias ));
 
 #endif /* _GPXE_SOCKET_H */
index c0fadd23d3eb984aa27cdb7ad782575c5be29221..9bc3cc4a7c7524cf1927019edb297a681bb758b2 100644 (file)
@@ -40,7 +40,7 @@ struct sockaddr_tcpip {
         */
        char pad[ sizeof ( struct sockaddr ) -
                  ( sizeof ( sa_family_t ) + sizeof ( uint16_t ) ) ];
-};
+} __attribute__ (( may_alias ));
 
 /** 
  * A transport-layer protocol of the TCP/IP stack (eg. UDP, TCP, etc)
index cb0e44ebe5182d83dbdf3c759d0748fe255d31e2..e515f6503f48c949cbbfd9b029bf9a1826dcb138 100644 (file)
@@ -15,7 +15,6 @@
 #include <gpxe/if_ether.h>
 
 struct xfer_interface;
-struct sockaddr;
 
 /**
  * UDP constants