Bläddra i källkod

[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 år sedan
förälder
incheckning
85e5e25c52

+ 2
- 2
src/include/gpxe/in.h Visa fil

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

+ 1
- 1
src/include/gpxe/open.h Visa fil

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

+ 1
- 1
src/include/gpxe/resolv.h Visa fil

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

+ 1
- 1
src/include/gpxe/socket.h Visa fil

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

+ 1
- 1
src/include/gpxe/tcpip.h Visa fil

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

+ 0
- 1
src/include/gpxe/udp.h Visa fil

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

Laddar…
Avbryt
Spara