From: Jonathan Cameron <jic23@kernel.org>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: Nathan Chancellor <natechancellor@gmail.com>,
Lee Jones <lee.jones@linaro.org>,
Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@st.com>,
Stefan Agner <stefan@agner.ch>,
Max Krummenacher <max.krummenacher@toradex.com>,
Philippe Schenker <philippe.schenker@toradex.com>,
linux-iio@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
Linux ARM <linux-arm-kernel@lists.infradead.org>,
LKML <linux-kernel@vger.kernel.org>,
clang-built-linux@googlegroups.com
Subject: Re: [PATCH] iio: adc: stmpe-adc: Shuffle an if statement around in stmpe_adc_isr
Date: Sun, 10 Mar 2019 09:45:56 +0000 [thread overview]
Message-ID: <20190310094556.3ae7c5fa@archlinux> (raw)
In-Reply-To: <CAKwvOdn4s_BdBPtOSyeQfRE+PCQLpDgm9VSkSR6eBkrBp_GhrA@mail.gmail.com>
On Thu, 7 Mar 2019 10:31:55 -0800
Nick Desaulniers <ndesaulniers@google.com> wrote:
> On Thu, Mar 7, 2019 at 9:16 AM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > When building with -Wsometimes-uninitialized, Clang warns:
> >
> > drivers/iio/adc/stmpe-adc.c:204:13: warning: variable 'data' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
> >
> > Clang can't tell that data will never be used uninitialized because the
> > two if statements take care of all cases. Remove the first if statement
> > and make it the else branch of the second one so that it is apparent to
> > Clang that all cases are covered.
> >
> > Link: https://github.com/ClangBuiltLinux/linux/issues/387
> > Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
>
> LGTM, thanks Nathan.
> Reviewed-by: NIck Desaulniers <ndesaulniers@google.com>
Agreed. Seems obviously correct. Stefan, I'm only pushing this out as
testing for now so happy to rebase if you have comments.
Thanks,
Jonathan
>
> > ---
> > drivers/iio/adc/stmpe-adc.c | 5 ++---
> > 1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c
> > index 37f4b74a5d32..7921f827c6ec 100644
> > --- a/drivers/iio/adc/stmpe-adc.c
> > +++ b/drivers/iio/adc/stmpe-adc.c
> > @@ -184,9 +184,6 @@ static irqreturn_t stmpe_adc_isr(int irq, void *dev_id)
> > struct stmpe_adc *info = (struct stmpe_adc *)dev_id;
> > u16 data;
> >
> > - if (info->channel > STMPE_TEMP_CHANNEL)
> > - return IRQ_NONE;
> > -
> > if (info->channel <= STMPE_ADC_LAST_NR) {
> > int int_sta;
> >
> > @@ -205,6 +202,8 @@ static irqreturn_t stmpe_adc_isr(int irq, void *dev_id)
> > /* Read value */
> > stmpe_block_read(info->stmpe, STMPE_REG_TEMP_DATA, 2,
> > (u8 *) &data);
> > + } else {
> > + return IRQ_NONE;
> > }
> >
> > info->value = (u32) be16_to_cpu(data);
> > --
> > 2.21.0
> >
>
>
WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <jic23@kernel.org>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: Max Krummenacher <max.krummenacher@toradex.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
clang-built-linux@googlegroups.com, linux-iio@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
Stefan Agner <stefan@agner.ch>,
Philippe Schenker <philippe.schenker@toradex.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Hartmut Knaack <knaack.h@gmx.de>,
Nathan Chancellor <natechancellor@gmail.com>,
Lee Jones <lee.jones@linaro.org>,
linux-stm32@st-md-mailman.stormreply.com,
Linux ARM <linux-arm-kernel@lists.infradead.org>,
Alexandre Torgue <alexandre.torgue@st.com>
Subject: Re: [PATCH] iio: adc: stmpe-adc: Shuffle an if statement around in stmpe_adc_isr
Date: Sun, 10 Mar 2019 09:45:56 +0000 [thread overview]
Message-ID: <20190310094556.3ae7c5fa@archlinux> (raw)
In-Reply-To: <CAKwvOdn4s_BdBPtOSyeQfRE+PCQLpDgm9VSkSR6eBkrBp_GhrA@mail.gmail.com>
On Thu, 7 Mar 2019 10:31:55 -0800
Nick Desaulniers <ndesaulniers@google.com> wrote:
> On Thu, Mar 7, 2019 at 9:16 AM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > When building with -Wsometimes-uninitialized, Clang warns:
> >
> > drivers/iio/adc/stmpe-adc.c:204:13: warning: variable 'data' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
> >
> > Clang can't tell that data will never be used uninitialized because the
> > two if statements take care of all cases. Remove the first if statement
> > and make it the else branch of the second one so that it is apparent to
> > Clang that all cases are covered.
> >
> > Link: https://github.com/ClangBuiltLinux/linux/issues/387
> > Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
>
> LGTM, thanks Nathan.
> Reviewed-by: NIck Desaulniers <ndesaulniers@google.com>
Agreed. Seems obviously correct. Stefan, I'm only pushing this out as
testing for now so happy to rebase if you have comments.
Thanks,
Jonathan
>
> > ---
> > drivers/iio/adc/stmpe-adc.c | 5 ++---
> > 1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c
> > index 37f4b74a5d32..7921f827c6ec 100644
> > --- a/drivers/iio/adc/stmpe-adc.c
> > +++ b/drivers/iio/adc/stmpe-adc.c
> > @@ -184,9 +184,6 @@ static irqreturn_t stmpe_adc_isr(int irq, void *dev_id)
> > struct stmpe_adc *info = (struct stmpe_adc *)dev_id;
> > u16 data;
> >
> > - if (info->channel > STMPE_TEMP_CHANNEL)
> > - return IRQ_NONE;
> > -
> > if (info->channel <= STMPE_ADC_LAST_NR) {
> > int int_sta;
> >
> > @@ -205,6 +202,8 @@ static irqreturn_t stmpe_adc_isr(int irq, void *dev_id)
> > /* Read value */
> > stmpe_block_read(info->stmpe, STMPE_REG_TEMP_DATA, 2,
> > (u8 *) &data);
> > + } else {
> > + return IRQ_NONE;
> > }
> >
> > info->value = (u32) be16_to_cpu(data);
> > --
> > 2.21.0
> >
>
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-03-10 9:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-07 17:16 [PATCH] iio: adc: stmpe-adc: Shuffle an if statement around in stmpe_adc_isr Nathan Chancellor
2019-03-07 17:16 ` Nathan Chancellor
2019-03-07 18:31 ` Nick Desaulniers
2019-03-07 18:31 ` Nick Desaulniers
2019-03-10 9:45 ` Jonathan Cameron [this message]
2019-03-10 9:45 ` Jonathan Cameron
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=20190310094556.3ae7c5fa@archlinux \
--to=jic23@kernel.org \
--cc=alexandre.torgue@st.com \
--cc=clang-built-linux@googlegroups.com \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=max.krummenacher@toradex.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=natechancellor@gmail.com \
--cc=ndesaulniers@google.com \
--cc=philippe.schenker@toradex.com \
--cc=pmeerw@pmeerw.net \
--cc=stefan@agner.ch \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.