linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ardelean, Alexandru" <alexandru.Ardelean@analog.com>
To: "Hennerich, Michael" <Michael.Hennerich@analog.com>,
	"jic23@kernel.org" <jic23@kernel.org>,
	"lars@metafoo.de" <lars@metafoo.de>,
	"beniamin.bia@analog.com" <beniamin.bia@analog.com>,
	"arnd@arndb.de" <arnd@arndb.de>,
	"Bogdan, Dragos" <Dragos.Bogdan@analog.com>
Cc: "Jonathan.Cameron@huawei.com" <Jonathan.Cameron@huawei.com>,
	"clang-built-linux@googlegroups.com" 
	<clang-built-linux@googlegroups.com>,
	"knaack.h@gmx.de" <knaack.h@gmx.de>,
	"pmeerw@pmeerw.net" <pmeerw@pmeerw.net>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] iio: adc: ad7476: fix clang -Wpointer-bool-conversion warning
Date: Tue, 5 May 2020 15:41:25 +0000	[thread overview]
Message-ID: <81fedffa59202e11e364abf44a3b529b4dfb98c8.camel@analog.com> (raw)
In-Reply-To: <20200505142408.1113763-1-arnd@arndb.de>

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 */
>  

  reply	other threads:[~2020-05-05 15:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-05 14:23 [PATCH] iio: adc: ad7476: fix clang -Wpointer-bool-conversion warning Arnd Bergmann
2020-05-05 15:41 ` Ardelean, Alexandru [this message]
2020-05-08 18:20 ` Nick Desaulniers

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=81fedffa59202e11e364abf44a3b529b4dfb98c8.camel@analog.com \
    --to=alexandru.ardelean@analog.com \
    --cc=Dragos.Bogdan@analog.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=arnd@arndb.de \
    --cc=beniamin.bia@analog.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /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).