[PATCH] Remove 64 bit compilation warnings

Shaun Jackman sjackman at gmail.com
Tue Nov 22 15:33:50 UTC 2005


2005/11/22, Rob Landley <rob at landley.net>:
> On Monday 21 November 2005 16:59, Shaw Vrana wrote:
> > Hi,
> >
> > Just a simple patch to remove a couple warnings I was seeing during a 64
> > bit compilation.
> >
> > Thanks,
> > Shaw
>
> Ash isn't my problem, but I'm curious what a double cast is doing in ifconfig.
> What's going on there?
>
> Rob

The double cast serves to mask a serious error by hiding information
from the compiler. The variable `i' is declared as an unsigned int,
which is not large enough to hold a pointer on certain platforms.
Casting first to an intptr_t, which is large enough, and then casting
to a caddr_t allows the compiler to believe it has enough information
to create a pointer, when in fact it does not.

I'm not familiar enough with the code to know what magic is going on
here with A_CAST_CHAR_PTR, but typically the correct solution would be
to change the `unsigned int i' on line 483 to an `intptr_t.

Cheers,
Shaun



More information about the busybox mailing list