Fix strict-aliasing warning in resolv/res_hconf.c
diff mbox

Message ID 555C48F0.2030208@redhat.com
State New
Headers show

Commit Message

Florian Weimer May 20, 2015, 8:42 a.m. UTC
On 05/20/2015 10:23 AM, Andreas Schwab wrote:
> Florian Weimer <fweimer@redhat.com> writes:
> 
>> Looking at struct ifreq, it is rather mysterious to me how this is
>> supposed to work at all.  I mean, struct sockaddr has just 14 bytes
>> storage for address information, but IPv6 addresses need 16 bytes, and
>> socket addresses contain even more information than a raw address.
> 
> This ioctl is only defined for IPv4.

Oh, but then we can add a union member of the appropriate type (just one
is needed):



This doesn't change ABI.  And then the code in resolv/res_hconf.c could
use that new member, without any casts.

Patch
diff mbox

diff --git a/sysdeps/gnu/net/if.h b/sysdeps/gnu/net/if.h
index 49a048c..39f40de 100644
--- a/sysdeps/gnu/net/if.h
+++ b/sysdeps/gnu/net/if.h
@@ -24,6 +24,7 @@ 
 #ifdef __USE_MISC
 # include <sys/types.h>
 # include <sys/socket.h>
+# include <netinet/in.h>
 #endif


@@ -139,6 +140,7 @@  struct ifreq
 	struct sockaddr ifru_broadaddr;
 	struct sockaddr ifru_netmask;
 	struct sockaddr ifru_hwaddr;
+	struct sockaddr_in ifru_addr_in;
 	short int ifru_flags;
 	int ifru_ivalue;
 	int ifru_mtu;