[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [lwip-devel] [bug #26273] etharp.c : fix alignment issue in etharp_r

From: Bill Auerbach
Subject: RE: [lwip-devel] [bug #26273] etharp.c : fix alignment issue in etharp_raw
Date: Tue, 21 Apr 2009 17:57:12 -0400

Casting pointers is not guaranteed to conform to alignment restrictions of the 
target processor.  Non-casted pointers to char, short, int, and long as well as 
implicit casts to these are safe.  If you can use standard C constructs without 
casts, it should both be portable and work on all platforms.  A bad aspect of C 
is that it has some portability shortcomings - pointer casting and bit-fields 
come to mind.  I always try to avoid all pointer casts other than to void * and 
char *.


>-----Original Message-----
>From: address@hidden
>[mailto:address@hidden On
>Behalf Of Guillaume du PONTAVICE
>Sent: Tuesday, April 21, 2009 5:45 PM
>To: Simon Goldschmidt; Guillaume du PONTAVICE; address@hidden
>Subject: [lwip-devel] [bug #26273] etharp.c : fix alignment issue in
>Follow-up Comment #2, bug #26273 (project lwip):
>well, in my case
>the beginning of the ARP packet is word aligned & hdr->sipaddr & hdr-
>are two bytes aligned (not 4 bytes aligned), as their offset in an ARP
>is only two bytes aligned.
>when writing on a non aligned address on ST20 chipset, no exception
>but this may result in corruption of adjacent memory.
>I guess the ST compiler try to optimize the cast & then generate a load
>/ store word instruction instead of two load short / store short
>I will have a look at the assembly dump tomorrow to confirm this.
>    _______________________________________________________
>Reply to this item at:
>  <http://savannah.nongnu.org/bugs/?26273>
>  Message posté via/par Savannah
>  http://savannah.nongnu.org/
>lwip-devel mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]