All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Andy Gross <andy.gross@linaro.org>,
	David Brown <david.brown@linaro.org>,
	Jonathan Cameron <jic23@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>, Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	linux-arm-msm@vger.kernel.org, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] iio: adc: fix uninitialized variable warning
Date: Mon,  4 Mar 2019 21:03:07 +0100	[thread overview]
Message-ID: <20190304200317.1229196-1-arnd@arndb.de> (raw)

The pm8xxx_xoadc_probe() function triggers a bogus warning
about an uninitialized variable:

drivers/iio/adc/qcom-pm8xxx-xoadc.c: In function 'pm8xxx_xoadc_probe':
drivers/iio/adc/qcom-pm8xxx-xoadc.c:633:8: error: 'ch' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Reword the function so the compiler can see more easily that it
is always initialized.

Fixes: 63c3ecd946d4 ("iio: adc: add a driver for Qualcomm PM8xxx HK/XOADC")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/iio/adc/qcom-pm8xxx-xoadc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/iio/adc/qcom-pm8xxx-xoadc.c b/drivers/iio/adc/qcom-pm8xxx-xoadc.c
index c30c002f1fef..7939238001c8 100644
--- a/drivers/iio/adc/qcom-pm8xxx-xoadc.c
+++ b/drivers/iio/adc/qcom-pm8xxx-xoadc.c
@@ -423,7 +423,7 @@ static irqreturn_t pm8xxx_eoc_irq(int irq, void *d)
 static struct pm8xxx_chan_info *
 pm8xxx_get_channel(struct pm8xxx_xoadc *adc, u8 chan)
 {
-	struct pm8xxx_chan_info *ch;
+	struct pm8xxx_chan_info *ch = NULL;
 	int i;
 
 	for (i = 0; i < adc->nchans; i++) {
@@ -431,8 +431,6 @@ pm8xxx_get_channel(struct pm8xxx_xoadc *adc, u8 chan)
 		if (ch->hwchan->amux_channel == chan)
 			break;
 	}
-	if (i == adc->nchans)
-		return NULL;
 
 	return ch;
 }
-- 
2.20.0

             reply	other threads:[~2019-03-04 20:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-04 20:03 Arnd Bergmann [this message]
2019-03-09 18:10 ` [PATCH] iio: adc: fix uninitialized variable warning 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=20190304200317.1229196-1-arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=andy.gross@linaro.org \
    --cc=david.brown@linaro.org \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-arm-msm@vger.kernel.org \
    --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.