From: Ben Pfaff Date: Tue, 15 Dec 2009 06:59:55 +0000 (-0800) Subject: netdev-linux: Fix aliasing error. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c100e025e2ca1bc330512e003bac8359ee65318d;p=openvswitch 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. --- 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);