Fix gcc warning per discussion on lwip-users 2006.04.25: dereferencing

type-punned pointer will break strict-aliasing rules.  Use memcpy
instead of structure copy; code is not in critical path.
This commit is contained in:
curtmcd 2006-05-26 19:05:41 +00:00
parent 076a884651
commit 0148128881

View File

@ -488,9 +488,10 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
hdr = p->payload; hdr = p->payload;
/* get aligned copies of addresses */ /* Copy struct ip_addr2 to aligned ip_addr, to support compilers without
*(struct ip_addr2 *)&sipaddr = hdr->sipaddr; * structure packing (not using structure copy which breaks strict-aliasing rules). */
*(struct ip_addr2 *)&dipaddr = hdr->dipaddr; memcpy(&sipaddr, &hdr->sipaddr, sizeof(sipaddr));
memcpy(&dipaddr, &hdr->dipaddr, sizeof(dipaddr));
/* this interface is not configured? */ /* this interface is not configured? */
if (netif->ip_addr.addr == 0) { if (netif->ip_addr.addr == 0) {