Work around some gcc 4.4 strict-aliasing warnings
gcc 4.4 ends up generating strict-aliasing warnings about some very common networking socket uses that do not really result in a real problem and cannot be easily avoided with union-based type-punning due to struct definitions including another struct in system header files. To avoid having to fully disable strict-aliasing warnings, provide a mechanism to hide the typecast from aliasing for now. A cleaner solution will hopefully be found in the future to handle these cases.
This commit is contained in:
parent
eb999fefcb
commit
0ae7b08691
6 changed files with 28 additions and 7 deletions
|
@ -185,7 +185,7 @@ int l2_packet_get_ip_addr(struct l2_packet_data *l2, char *buf, size_t len)
|
|||
return -1;
|
||||
}
|
||||
close(s);
|
||||
saddr = (struct sockaddr_in *) &ifr.ifr_addr;
|
||||
saddr = aliasing_hide_typecast(&ifr.ifr_addr, struct sockaddr_in);
|
||||
if (saddr->sin_family != AF_INET)
|
||||
return -1;
|
||||
res = os_strlcpy(buf, inet_ntoa(saddr->sin_addr), len);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue