« Return to Thread: [PATCH] Fix aliasing violation.

RE: [PATCH] Fix aliasing violation.

by Bill Auerbach :: Rate this Message:

Reply to Author | View in Thread

But we should use SMEMCPY.  I use a macro that converts this to a series of inline load/stores.

Bill

> -----Original Message-----
> From: lwip-devel-bounces+bauerbach=arrayonline.com@...
> [mailto:lwip-devel-bounces+bauerbach=arrayonline.com@...] On
> Behalf Of David Woodhouse
> Sent: Friday, October 03, 2008 5:43 AM
> To: lwip-devel
> Subject: [lwip-devel] [PATCH] Fix aliasing violation.
>
> src/netif/etharp.c: In function ‘etharp_arp_input’:
> src/netif/etharp.c:708: warning: dereferencing type-punned pointer will
> break strict-aliasing rules
>
> Index: src/netif/etharp.c
> ===================================================================
> RCS file: /sources/lwip/lwip/src/netif/etharp.c,v
> retrieving revision 1.148
> diff -u -p -r1.148 etharp.c
> --- src/netif/etharp.c 19 Jun 2008 16:40:59 -0000 1.148
> +++ src/netif/etharp.c 3 Oct 2008 09:39:55 -0000
> @@ -705,7 +705,7 @@ etharp_arp_input(struct netif *netif, st
>        hdr->opcode = htons(ARP_REPLY);
>
>        hdr->dipaddr = hdr->sipaddr;
> -      hdr->sipaddr = *(struct ip_addr2 *)&netif->ip_addr;
> +      memcpy(&hdr->sipaddr, &netif->ip_addr, sizeof(hdr->sipaddr));
>
>        LWIP_ASSERT("netif->hwaddr_len must be the same as
> ETHARP_HWADDR_LEN for etharp!",
>                    (netif->hwaddr_len == ETHARP_HWADDR_LEN));
>
> --
> David Woodhouse                            Open Source Technology
> Centre
> David.Woodhouse@...                              Intel
> Corporation
>
>
>
> _______________________________________________
> lwip-devel mailing list
> lwip-devel@...
> http://lists.nongnu.org/mailman/listinfo/lwip-devel



_______________________________________________
lwip-devel mailing list
lwip-devel@...
http://lists.nongnu.org/mailman/listinfo/lwip-devel

 « Return to Thread: [PATCH] Fix aliasing violation.