* [PATCH] iio: adc: ad7476: fix clang -Wpointer-bool-conversion warning
@ 2020-05-05 14:23 Arnd Bergmann
2020-05-05 15:41 ` Ardelean, Alexandru
2020-05-08 18:20 ` Nick Desaulniers
0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2020-05-05 14:23 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
Dragos Bogdan, Beniamin Bia
Cc: Arnd Bergmann, Jonathan Cameron, Hartmut Knaack,
Peter Meerwald-Stadler, linux-iio, linux-kernel,
clang-built-linux
Checking the pointer value of st->chip_info->convst_channel is pointless
since this this an array inside of a struct: even if st->chip_info is NULL,
the pointer is non-zero. Clang warns about this:
drivers/iio/adc/ad7476.c:312:40: warning: address of array 'st->chip_info->convst_channel' will always evaluate to 'true' [-Wpointer-bool-conversion]
if (st->convst_gpio && st->chip_info->convst_channel)
~~ ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
I could not come up with a sane way to check whether the entry
is valid, so just remove the check and keep the behavior as it
is today but without the warning.
Fixes: 3a6af93dd66e ("iio: adc: ad7476: Add IIO_CHAN_INFO_RAW for AD7091R")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/iio/adc/ad7476.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
index e9984a38fc4c..4e816d714ad2 100644
--- a/drivers/iio/adc/ad7476.c
+++ b/drivers/iio/adc/ad7476.c
@@ -309,7 +309,7 @@ static int ad7476_probe(struct spi_device *spi)
indio_dev->num_channels = 2;
indio_dev->info = &ad7476_info;
- if (st->convst_gpio && st->chip_info->convst_channel)
+ if (st->convst_gpio)
indio_dev->channels = st->chip_info->convst_channel;
/* Setup default message */
--
2.26.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: adc: ad7476: fix clang -Wpointer-bool-conversion warning
2020-05-05 14:23 [PATCH] iio: adc: ad7476: fix clang -Wpointer-bool-conversion warning Arnd Bergmann
@ 2020-05-05 15:41 ` Ardelean, Alexandru
2020-05-08 18:20 ` Nick Desaulniers
1 sibling, 0 replies; 3+ messages in thread
From: Ardelean, Alexandru @ 2020-05-05 15:41 UTC (permalink / raw)
To: Hennerich, Michael, jic23, lars, beniamin.bia, arnd, Bogdan, Dragos
Cc: Jonathan.Cameron, clang-built-linux, knaack.h, pmeerw, linux-iio,
linux-kernel
On Tue, 2020-05-05 at 16:23 +0200, Arnd Bergmann wrote:
> [External]
>
> Checking the pointer value of st->chip_info->convst_channel is pointless
> since this this an array inside of a struct: even if st->chip_info is NULL,
> the pointer is non-zero. Clang warns about this:
>
> drivers/iio/adc/ad7476.c:312:40: warning: address of array 'st->chip_info-
> >convst_channel' will always evaluate to 'true' [-Wpointer-bool-conversion]
> if (st->convst_gpio && st->chip_info->convst_channel)
> ~~ ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
>
> I could not come up with a sane way to check whether the entry
> is valid, so just remove the check and keep the behavior as it
> is today but without the warning.
There's already a patch for this, in one of Jonathan's branches.
https://patchwork.kernel.org/patch/11507829/
Thanks
Alex
>
> Fixes: 3a6af93dd66e ("iio: adc: ad7476: Add IIO_CHAN_INFO_RAW for AD7091R")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/iio/adc/ad7476.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
> index e9984a38fc4c..4e816d714ad2 100644
> --- a/drivers/iio/adc/ad7476.c
> +++ b/drivers/iio/adc/ad7476.c
> @@ -309,7 +309,7 @@ static int ad7476_probe(struct spi_device *spi)
> indio_dev->num_channels = 2;
> indio_dev->info = &ad7476_info;
>
> - if (st->convst_gpio && st->chip_info->convst_channel)
> + if (st->convst_gpio)
> indio_dev->channels = st->chip_info->convst_channel;
> /* Setup default message */
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: adc: ad7476: fix clang -Wpointer-bool-conversion warning
2020-05-05 14:23 [PATCH] iio: adc: ad7476: fix clang -Wpointer-bool-conversion warning Arnd Bergmann
2020-05-05 15:41 ` Ardelean, Alexandru
@ 2020-05-08 18:20 ` Nick Desaulniers
1 sibling, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2020-05-08 18:20 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
Dragos Bogdan, Beniamin Bia, Jonathan Cameron, Hartmut Knaack,
Peter Meerwald-Stadler, linux-iio, LKML, clang-built-linux
On Tue, May 5, 2020 at 7:24 AM Arnd Bergmann <arnd@arndb.de> wrote:
>
> Checking the pointer value of st->chip_info->convst_channel is pointless
> since this this an array inside of a struct: even if st->chip_info is NULL,
> the pointer is non-zero. Clang warns about this:
>
> drivers/iio/adc/ad7476.c:312:40: warning: address of array 'st->chip_info->convst_channel' will always evaluate to 'true' [-Wpointer-bool-conversion]
> if (st->convst_gpio && st->chip_info->convst_channel)
> ~~ ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
>
> I could not come up with a sane way to check whether the entry
> is valid, so just remove the check and keep the behavior as it
> is today but without the warning.
Me too. Thanks for the patch.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
>
> Fixes: 3a6af93dd66e ("iio: adc: ad7476: Add IIO_CHAN_INFO_RAW for AD7091R")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/iio/adc/ad7476.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
> index e9984a38fc4c..4e816d714ad2 100644
> --- a/drivers/iio/adc/ad7476.c
> +++ b/drivers/iio/adc/ad7476.c
> @@ -309,7 +309,7 @@ static int ad7476_probe(struct spi_device *spi)
> indio_dev->num_channels = 2;
> indio_dev->info = &ad7476_info;
>
> - if (st->convst_gpio && st->chip_info->convst_channel)
> + if (st->convst_gpio)
> indio_dev->channels = st->chip_info->convst_channel;
> /* Setup default message */
>
> --
> 2.26.0
>
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20200505142408.1113763-1-arnd%40arndb.de.
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-08 18:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-05 14:23 [PATCH] iio: adc: ad7476: fix clang -Wpointer-bool-conversion warning Arnd Bergmann
2020-05-05 15:41 ` Ardelean, Alexandru
2020-05-08 18:20 ` Nick Desaulniers
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).