From c100e025e2ca1bc330512e003bac8359ee65318d Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 14 Dec 2009 22:59:55 -0800 Subject: [PATCH] netdev-linux: Fix aliasing error. The latest version of GCC flags a common socket convention as breaking strict-aliasing rules. This commit removes the aliasing and gets rid of the scary warning. --- lib/netdev-linux.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 0dff5082..18d32742 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -1710,14 +1710,14 @@ netdev_linux_arp_lookup(const struct netdev *netdev, uint32_t ip, uint8_t mac[ETH_ADDR_LEN]) { struct arpreq r; - struct sockaddr_in *pa; + struct sockaddr_in sin; int retval; memset(&r, 0, sizeof r); - pa = (struct sockaddr_in *) &r.arp_pa; - pa->sin_family = AF_INET; - pa->sin_addr.s_addr = ip; - pa->sin_port = 0; + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = ip; + sin.sin_port = 0; + memcpy(&r.arp_pa, &sin, sizeof sin); r.arp_ha.sa_family = ARPHRD_ETHER; r.arp_flags = 0; strncpy(r.arp_dev, netdev->name, sizeof r.arp_dev); -- 2.30.2