Fix strict-aliasing warning in resolv/res_hconf.c
Commit Message
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.
@@ -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;