There are now two remaining warnings.

Rob Landley rob at landley.net
Thu Sep 8 03:03:33 UTC 2005


On Wednesday 07 September 2005 13:34, Robin Farine wrote:
> On Wed September 7 2005 14:41, Rainer Weikusat wrote:
> > There is no need to speculate here, because the message means
> > exactly what it says: As of C99, no objects of different types
> > are allowed to alias each other (sole exception is char), which
> > means that the compiler may assume that the value of 'aligned'
> > does not change due to indirect accesses (ie through pointers)
> > except if the pointer is an u32 * (or a char *).
>
> And how about this? If I understand the constraints on simple
> assignment correctly ...

You're just hiding a void * cast there...

Apparently the warning is that having two pointers that point to the same 
memory location as different data types breaks "strict aliasing" which is a 
thing that allows more compiler optimizations.  But it _also_ tends to be 
endian unsafe.

Sigh, time to read the code and see what it's actually doing...

(Ow.  Pain pain pain.)  Ok, I read through trough add_option_string and 
end_option as well (P.S.  "Ouch.") to figure out what it's doing, and here's 
me ripping that function out with extreme prejudice and replacing it with 
something half-sane.

The only way this function can ever have worked is if the data being passed in 
is already in network byte order.  (Could somebody on a __BIG_ENDIAN platform 
please test that part of it and make sure life is good?)

P.S.  This shrinks add_simple_option from 0x96 bytes to 0x56 bytes.

Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: udhcpopt.diff
Type: text/x-diff
Size: 1623 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20050907/53963df2/attachment.bin 


More information about the busybox mailing list