From 85e5e25c52834788239eb8b6c94e0d3aeddd2705 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 5 Jan 2009 19:19:23 -0800 Subject: [PATCH] [build] Avoid strict-aliasing warnings when building with gcc 4.4 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 | 4 ++-- src/include/gpxe/open.h | 2 +- src/include/gpxe/resolv.h | 2 +- src/include/gpxe/socket.h | 2 +- src/include/gpxe/tcpip.h | 2 +- src/include/gpxe/udp.h | 1 - 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/include/gpxe/in.h b/src/include/gpxe/in.h index 40e4d407..831a6110 100644 --- a/src/include/gpxe/in.h +++ b/src/include/gpxe/in.h @@ -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 ); diff --git a/src/include/gpxe/open.h b/src/include/gpxe/open.h index beab0a1f..81d5fc24 100644 --- a/src/include/gpxe/open.h +++ b/src/include/gpxe/open.h @@ -9,10 +9,10 @@ #include #include +#include struct xfer_interface; struct uri; -struct sockaddr; /** Location types */ enum { diff --git a/src/include/gpxe/resolv.h b/src/include/gpxe/resolv.h index 7c1ee6e2..e73c8201 100644 --- a/src/include/gpxe/resolv.h +++ b/src/include/gpxe/resolv.h @@ -10,8 +10,8 @@ #include #include #include +#include -struct sockaddr; struct resolv_interface; /** Name resolution interface operations */ diff --git a/src/include/gpxe/socket.h b/src/include/gpxe/socket.h index 582de4ef..b683bed6 100644 --- a/src/include/gpxe/socket.h +++ b/src/include/gpxe/socket.h @@ -94,6 +94,6 @@ struct sockaddr { * family. */ char pad[ SA_LEN - sizeof ( sa_family_t ) ]; -}; +} __attribute__ (( may_alias )); #endif /* _GPXE_SOCKET_H */ diff --git a/src/include/gpxe/tcpip.h b/src/include/gpxe/tcpip.h index c0fadd23..9bc3cc4a 100644 --- a/src/include/gpxe/tcpip.h +++ b/src/include/gpxe/tcpip.h @@ -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) diff --git a/src/include/gpxe/udp.h b/src/include/gpxe/udp.h index cb0e44eb..e515f650 100644 --- a/src/include/gpxe/udp.h +++ b/src/include/gpxe/udp.h @@ -15,7 +15,6 @@ #include struct xfer_interface; -struct sockaddr; /** * UDP constants