From: Jonathan Cameron <jic23@kernel.org>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Nicholas Mc Guire <der.herr@hofr.at>,
Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: pressure: zpa2326: Remove always-true check which confuses gcc
Date: Mon, 25 Sep 2017 21:39:46 +0100 [thread overview]
Message-ID: <20170925213946.1d2c9824@archlinux> (raw)
In-Reply-To: <1499242499-18860-1-git-send-email-geert@linux-m68k.org>
On Wed, 5 Jul 2017 10:14:59 +0200
Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> With gcc 4.1.2:
>
> drivers/iio/pressure/zpa2326.c: In function ‘zpa2326_wait_oneshot_completion’:
> drivers/iio/pressure/zpa2326.c:868: warning: ‘ret’ may be used uninitialized in this function
>
> When testing for "timeout < 0", timeout is already guaranteed to be
> strict negative, so the branch is always taken, and ret is thus always
> initialized. But (some version of) gcc is not smart enough to notice.
>
> Remove the check to fix this.
> As there is no other code in between assigning the error codes and
> returning them, the error codes can be returned immediately, and the
> intermediate variable can be dropped.
> Drop the "else" to please checkpatch.
>
> Fixes: e7215fe4d51e69c9 ("iio: pressure: zpa2326: report interrupted case as failure")
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Sorry - this one got missed originally. Not quite sure why!
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.
Thanks,
Jonathan
> ---
> drivers/iio/pressure/zpa2326.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c
> index c92a95f9f52c2141..531b88ce336184d4 100644
> --- a/drivers/iio/pressure/zpa2326.c
> +++ b/drivers/iio/pressure/zpa2326.c
> @@ -865,7 +865,6 @@ static irqreturn_t zpa2326_handle_threaded_irq(int irq, void *data)
> static int zpa2326_wait_oneshot_completion(const struct iio_dev *indio_dev,
> struct zpa2326_private *private)
> {
> - int ret;
> unsigned int val;
> long timeout;
>
> @@ -887,14 +886,11 @@ static int zpa2326_wait_oneshot_completion(const struct iio_dev *indio_dev,
> /* Timed out. */
> zpa2326_warn(indio_dev, "no one shot interrupt occurred (%ld)",
> timeout);
> - ret = -ETIME;
> - } else if (timeout < 0) {
> - zpa2326_warn(indio_dev,
> - "wait for one shot interrupt cancelled");
> - ret = -ERESTARTSYS;
> + return -ETIME;
> }
>
> - return ret;
> + zpa2326_warn(indio_dev, "wait for one shot interrupt cancelled");
> + return -ERESTARTSYS;
> }
>
> static int zpa2326_init_managed_irq(struct device *parent,
prev parent reply other threads:[~2017-09-25 20:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-05 8:14 [PATCH] iio: pressure: zpa2326: Remove always-true check which confuses gcc Geert Uytterhoeven
2017-09-25 20:39 ` Jonathan Cameron [this message]
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=20170925213946.1d2c9824@archlinux \
--to=jic23@kernel.org \
--cc=der.herr@hofr.at \
--cc=geert@linux-m68k.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 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.