linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@gmail.com>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Liam Girdwood <lrg@ti.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] regulator: core: Add intermediate cast to uintptr_t before casting to pointer
Date: Wed, 01 Aug 2012 00:08:08 +0800	[thread overview]
Message-ID: <1343750888.5463.5.camel@phoenix> (raw)
In-Reply-To: <20120731154153.GI4468@opensource.wolfsonmicro.com>

於 二,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




  reply	other threads:[~2012-07-31 16:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-29 23:47 [PATCH] regulator: core: Add intermediate cast to uintptr_t before casting to pointer Axel Lin
2012-07-30 15:33 ` Mark Brown
2012-07-31  2:21   ` Axel Lin
2012-07-31 15:41     ` Mark Brown
2012-07-31 16:08       ` Axel Lin [this message]
2012-08-02 18:00         ` Mark Brown
2012-08-05 16:10           ` Axel Lin
2012-08-06 14:31             ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1343750888.5463.5.camel@phoenix \
    --to=axel.lin@gmail.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).