lwip-devel
[Top][All Lists]
Advanced

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

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


From: Bill Auerbach
Subject: [lwip-devel] [bug #26273] etharp.c : fix alignment issue in etharp_raw
Date: Wed, 22 Apr 2009 17:16:19 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8

Follow-up Comment #9, bug #26273 (project lwip):

> then either sipaddr or dipaddr is not four-byte aligned (MAC addresses are
6-byte long). The question appears, how the statement
> 
>hdr->dipaddr = hdr->sipaddr;
>
>(struct to struct copy) is translated by a compiler.

Because there is no cast! The compiler has all the information it needs to
generate correct code.  It knows the base of the struct is aligned and that a
sub-structure isn’t (because of packing).

A cast tells the compiler "I know what I’m doing".  Therefore, the code
with the cast had better ensure alignment, because the compiler will not.

Bill


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?26273>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/





reply via email to

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