於 二,2012-07-31 於 16:41 +0100,Mark Brown 提到:
> On Tue, Jul 31, 2012 at 10:21:56AM +0800, Axel Lin wrote:
> > 於 一,2012-07-30 於 16:33 +0100,Mark Brown 提到:
> > > On Mon, Jul 30, 2012 at 07:47:13AM +0800, Axel Lin wrote:
> 
> > > >                 _notifier_call_chain(rdev, 
> > > > REGULATOR_EVENT_VOLTAGE_CHANGE,
> > > > -                                    (void *)best_val);
> > > > +                                    (void *)(uintptr_t)best_val);
> 
> > > This also looks problematic, you should never need to cast a pointer to
> > > or from void.
> 
> > If I remove the cast to (void *), I got below build warning:
> 
> >   CC      drivers/regulator/core.o
> > drivers/regulator/core.c: In function '_regulator_do_set_voltage':
> > drivers/regulator/core.c:2183:10: warning: passing argument 3 of
> > '_notifier_call_chain' makes pointer from integer without a cast
> > [enabled by default]
> > drivers/regulator/core.c:94:13: note: expected 'void *' but argument is
> > of type 'long unsigned int'
> 
> So the above cast probably isn't right...  you shouldn't need a double
> cast here.

The issue of original warning is: ( I compile the kernel on x86_64 )
        warning: cast to pointer from integer of different size

What this patch does is:
cast best_val to uintptr_t, which is an unsigned integer large enough to
hold a void* pointer.

And then cast it to (void *).

Thus I did (void *)(uintptr_t)best_val.

Regards,
Axel



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to