Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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)).
  • Loading branch information
Michael Brown committed Jan 6, 2009
1 parent 21cfab4 commit 85e5e25
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/include/gpxe/in.h
Expand Up @@ -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
Expand All @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/include/gpxe/open.h
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/include/gpxe/resolv.h
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion src/include/gpxe/socket.h
Expand Up @@ -94,6 +94,6 @@ struct sockaddr {
* family.
*/
char pad[ SA_LEN - sizeof ( sa_family_t ) ];
};
} __attribute__ (( may_alias ));

#endif /* _GPXE_SOCKET_H */
2 changes: 1 addition & 1 deletion src/include/gpxe/tcpip.h
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/include/gpxe/udp.h
Expand Up @@ -15,7 +15,6 @@
#include <gpxe/if_ether.h>

struct xfer_interface;
struct sockaddr;

/**
* UDP constants
Expand Down

0 comments on commit 85e5e25

Please sign in to comment.