[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e5279ea9dfab400c8e6cd9346fb41a1d@AcuMS.aculab.com>
Date: Mon, 23 Jan 2023 09:26:17 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Javier Martinez Canillas' <javierm@...hat.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC: Thomas Zimmermann <tzimmermann@...e.de>,
Daniel Vetter <daniel@...ll.ch>,
David Airlie <airlied@...il.com>,
"dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>
Subject: RE: [PATCH] drm/ssd130x: Silence a `dubious: x & !y` warning
From: Javier Martinez Canillas
> Sent: 21 January 2023 19:10
>
> The sparse tool complains with the following warning:
>
> $ make M=drivers/gpu/drm/solomon/ C=2
> CC [M] drivers/gpu/drm/solomon/ssd130x.o
> CHECK drivers/gpu/drm/solomon/ssd130x.c
> drivers/gpu/drm/solomon/ssd130x.c:363:21: warning: dubious: x & !y
>
> This seems to be a false positive in my opinion but still we can silence
> the tool while making the code easier to read. Let's also add a comment,
> to explain why the "com_seq" logical not is used rather than its value.
>
> Reported-by: Thomas Zimmermann <tzimmermann@...e.de>
> Signed-off-by: Javier Martinez Canillas <javierm@...hat.com>
> Reviewed-by: Thomas Zimmermann <tzimmermann@...e.de>
> ---
>
> drivers/gpu/drm/solomon/ssd130x.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c
> index c3bf3a18302e..b16330a8b624 100644
> --- a/drivers/gpu/drm/solomon/ssd130x.c
> +++ b/drivers/gpu/drm/solomon/ssd130x.c
> @@ -81,7 +81,7 @@
> #define SSD130X_SET_PRECHARGE_PERIOD2_MASK GENMASK(7, 4)
> #define SSD130X_SET_PRECHARGE_PERIOD2_SET(val) FIELD_PREP(SSD130X_SET_PRECHARGE_PERIOD2_MASK, (val))
> #define SSD130X_SET_COM_PINS_CONFIG1_MASK GENMASK(4, 4)
> -#define SSD130X_SET_COM_PINS_CONFIG1_SET(val) FIELD_PREP(SSD130X_SET_COM_PINS_CONFIG1_MASK, !(val))
> +#define SSD130X_SET_COM_PINS_CONFIG1_SET(val) FIELD_PREP(SSD130X_SET_COM_PINS_CONFIG1_MASK, (val))
How about just changing !(val) to (val) ? 0 : 1
It should shut the compiler up and is probably more descriptive.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists