[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] [PATCH] fix warning for gcc and possible unaligned access
From: |
Pedro Alves |
Subject: |
[lwip-users] [PATCH] fix warning for gcc and possible unaligned access |
Date: |
Tue, 18 Apr 2006 11:46:02 +0100 |
User-agent: |
Mozilla Thunderbird 1.0.2 (Windows/20050317) |
This patch fixes this catched by gcc:
$ make
(...)/lwip/src/netif/etharp.c
(...)/lwip/src/netif/etharp.c: In function 'etharp_arp_input':
(...)/lwip/src/netif/etharp.c:505: warning: dereferencing type-punned
pointer will break strict-aliasing rules
(...)/lwip/src/netif/etharp.c:506: warning: dereferencing type-punned
pointer will break strict-aliasing rules
We could also use memcpy here, but that seems overkill for copying 8 bytes.
Cheers,
Pedro Alves
Index: src/netif/etharp.c
===================================================================
RCS file: /sources/lwip/lwip/src/netif/etharp.c,v
retrieving revision 1.94
diff -u -r1.94 etharp.c
--- src/netif/etharp.c 29 Mar 2006 13:16:40 -0000 1.94
+++ src/netif/etharp.c 18 Apr 2006 10:41:47 -0000
@@ -487,10 +487,11 @@
}
hdr = p->payload;
-
/* get aligned copies of addresses */
- *(struct ip_addr2 *)&sipaddr = hdr->sipaddr;
- *(struct ip_addr2 *)&dipaddr = hdr->dipaddr;
+ for(i=0; i<sizeof(hdr->sipaddr); i++)
+ ((u8_t*)&sipaddr)[i] = ((u8_t*)&hdr->sipaddr)[i];
+ for(i=0; i<sizeof(hdr->dipaddr); i++)
+ ((u8_t*)&dipaddr)[i] = ((u8_t*)&hdr->dipaddr)[i];
/* this interface is not configured? */
if (netif->ip_addr.addr == 0) {
- [lwip-users] [PATCH] fix warning for gcc and possible unaligned access,
Pedro Alves <=
- Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, beach . dk, 2006/04/18
- Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Pedro Alves, 2006/04/18
- Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Timmy Brolin, 2006/04/19
- Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Pedro Alves, 2006/04/21
- RE: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Curt McDowell, 2006/04/21
- Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Pedro Alves, 2006/04/21
- RE: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Curt McDowell, 2006/04/21
- Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Timmy Brolin, 2006/04/22
- Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access, Pedro Alves, 2006/04/22
- [lwip-users] Re: unix simhost, YH, 2006/04/22