lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230818160648.GA939927@dev-arch.thelio-3990X>
Date:   Fri, 18 Aug 2023 09:06:48 -0700
From:   Nathan Chancellor <nathan@...nel.org>
To:     Lee Jones <lee@...nel.org>
Cc:     Justin Stitt <justinstitt@...gle.com>, Pavel Machek <pavel@....cz>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Tom Rix <trix@...hat.com>, linux-leds@...r.kernel.org,
        linux-kernel@...r.kernel.org, llvm@...ts.linux.dev
Subject: Re: [PATCH] leds: pca955x: fix -Wvoid-pointer-to-enum-cast warning

On Fri, Aug 18, 2023 at 05:01:54PM +0100, Lee Jones wrote:
> On Wed, 16 Aug 2023, Justin Stitt wrote:
> 
> > When building with clang 18 I see the following warning:
> > |      drivers/leds/leds-pca955x.c:487:15: warning: cast to smaller integer
> > |      type 'enum pca955x_type' from 'const void *' [-Wvoid-pointer-to-enum-cast]
> > |        487 |                 chip_type = (enum pca955x_type)md;
> > 
> > This is due to the fact that `md` is a void* while `enum pca995x_type` has the
> > size of an int.
> > 
> > Add uintptr_t cast to silence clang warning while also keeping enum cast
> > for readability and consistency with other `chip_type` assignment just a
> > few lines below:
> > |	chip_type = (enum pca955x_type)id->driver_data;
> > 
> > Link: https://github.com/ClangBuiltLinux/linux/issues/1910
> > Reported-by: Nathan Chancellor <nathan@...nel.org>
> 
> A review from Nathan would be good here.

Reviewed-by: Nathan Chancellor <nathan@...nel.org>

> > Signed-off-by: Justin Stitt <justinstitt@...gle.com>
> 
> Also please make checkpatch.pl happy before resending, thanks.
> 
> > ---
> > 
> > 
> > leds: pca955x: fix -Wvoid-pointer-to-enum-cast warning
> > ---
> > Note: I've opted to keep the initial `enum pca955x_type` cast and just
> > place the uintptr_t cast first to silence the warning. It seemed weird
> > to me to see the same variable being assigned to two different casted
> > values within just a few lines.
> > ---
> >  drivers/leds/leds-pca955x.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c
> > index b10e1ef38db0..1d7fa0cd97bf 100644
> > --- a/drivers/leds/leds-pca955x.c
> > +++ b/drivers/leds/leds-pca955x.c
> > @@ -484,7 +484,7 @@ static int pca955x_probe(struct i2c_client *client)
> >  	const void *md = device_get_match_data(&client->dev);
> >  
> >  	if (md) {
> > -		chip_type = (enum pca955x_type)md;
> > +		chip_type = (enum pca955x_type)(uintptr_t)md;
> >  	} else {
> >  		const struct i2c_device_id *id = i2c_match_id(pca955x_id,
> >  							      client);
> > 
> > ---
> > base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421
> > change-id: 20230816-void-drivers-leds-leds-pca955x-7002cc67a291
> > 
> > Best regards,
> > --
> > Justin Stitt <justinstitt@...gle.com>
> > 
> 
> -- 
> Lee Jones [李琼斯]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ