Browse Source

[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)).
tags/v0.9.7
Michael Brown 16 years ago
parent
commit
85e5e25c52

+ 2
- 2
src/include/gpxe/in.h View File

71
 	char pad[ sizeof ( struct sockaddr ) - sizeof ( sa_family_t )
71
 	char pad[ sizeof ( struct sockaddr ) - sizeof ( sa_family_t )
72
 					     - sizeof ( uint16_t )
72
 					     - sizeof ( uint16_t )
73
 					     - sizeof ( struct in_addr ) ];
73
 					     - sizeof ( struct in_addr ) ];
74
-};
74
+} __attribute__ (( may_alias ));
75
 
75
 
76
 /**
76
 /**
77
  * IPv6 socket address
77
  * IPv6 socket address
87
         uint32_t        sin6_flowinfo;  /* Flow number */
87
         uint32_t        sin6_flowinfo;  /* Flow number */
88
         struct in6_addr sin6_addr;      /* 128-bit destination address */
88
         struct in6_addr sin6_addr;      /* 128-bit destination address */
89
         uint32_t        sin6_scope_id;  /* Scope ID */
89
         uint32_t        sin6_scope_id;  /* Scope ID */
90
-};
90
+} __attribute__ (( may_alias ));
91
 
91
 
92
 extern int inet_aton ( const char *cp, struct in_addr *inp );
92
 extern int inet_aton ( const char *cp, struct in_addr *inp );
93
 extern char * inet_ntoa ( struct in_addr in );
93
 extern char * inet_ntoa ( struct in_addr in );

+ 1
- 1
src/include/gpxe/open.h View File

9
 
9
 
10
 #include <stdarg.h>
10
 #include <stdarg.h>
11
 #include <gpxe/tables.h>
11
 #include <gpxe/tables.h>
12
+#include <gpxe/socket.h>
12
 
13
 
13
 struct xfer_interface;
14
 struct xfer_interface;
14
 struct uri;
15
 struct uri;
15
-struct sockaddr;
16
 
16
 
17
 /** Location types */
17
 /** Location types */
18
 enum {
18
 enum {

+ 1
- 1
src/include/gpxe/resolv.h View File

10
 #include <gpxe/refcnt.h>
10
 #include <gpxe/refcnt.h>
11
 #include <gpxe/interface.h>
11
 #include <gpxe/interface.h>
12
 #include <gpxe/tables.h>
12
 #include <gpxe/tables.h>
13
+#include <gpxe/socket.h>
13
 
14
 
14
-struct sockaddr;
15
 struct resolv_interface;
15
 struct resolv_interface;
16
 
16
 
17
 /** Name resolution interface operations */
17
 /** Name resolution interface operations */

+ 1
- 1
src/include/gpxe/socket.h View File

94
 	 * family.
94
 	 * family.
95
 	 */
95
 	 */
96
 	char pad[ SA_LEN - sizeof ( sa_family_t ) ];
96
 	char pad[ SA_LEN - sizeof ( sa_family_t ) ];
97
-};
97
+} __attribute__ (( may_alias ));
98
 
98
 
99
 #endif /* _GPXE_SOCKET_H */
99
 #endif /* _GPXE_SOCKET_H */

+ 1
- 1
src/include/gpxe/tcpip.h View File

40
 	 */
40
 	 */
41
 	char pad[ sizeof ( struct sockaddr ) -
41
 	char pad[ sizeof ( struct sockaddr ) -
42
 		  ( sizeof ( sa_family_t ) + sizeof ( uint16_t ) ) ];
42
 		  ( sizeof ( sa_family_t ) + sizeof ( uint16_t ) ) ];
43
-};
43
+} __attribute__ (( may_alias ));
44
 
44
 
45
 /** 
45
 /** 
46
  * A transport-layer protocol of the TCP/IP stack (eg. UDP, TCP, etc)
46
  * A transport-layer protocol of the TCP/IP stack (eg. UDP, TCP, etc)

+ 0
- 1
src/include/gpxe/udp.h View File

15
 #include <gpxe/if_ether.h>
15
 #include <gpxe/if_ether.h>
16
 
16
 
17
 struct xfer_interface;
17
 struct xfer_interface;
18
-struct sockaddr;
19
 
18
 
20
 /**
19
 /**
21
  * UDP constants
20
  * UDP constants

Loading…
Cancel
Save