public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Andrew F. Davis" <afd@ti.com>
To: Arnd Bergmann <arnd@arndb.de>, Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Mark Brown <broonie@kernel.org>,
	Javier Martinez Canillas <javier@osg.samsung.com>,
	<linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] iio: as3935: improve error reporting in as3935_event_work
Date: Tue, 31 May 2016 09:53:54 -0500	[thread overview]
Message-ID: <574DA582.50408@ti.com> (raw)
In-Reply-To: <1464619938-988956-1-git-send-email-arnd@arndb.de>

On 05/30/2016 09:52 AM, Arnd Bergmann wrote:
> gcc warns about a potentially uninitialized variable use
> in as3935_event_work:
> 
> drivers/iio/proximity/as3935.c: In function ‘as3935_event_work’:
> drivers/iio/proximity/as3935.c:231:6: error: ‘val’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> This case specifically happens when spi_w8r8() fails with a
> negative return code. We check all other users of this function
> except this one.
> 
> As the error is rather unlikely to happen after the device
> has already been initialized, this just adds a dev_warn().
> Another warning already existst in the same function, but is

                            ^^ typo

> missing a trailing '\n' character, so I'm fixing that too.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/iio/proximity/as3935.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c
> index f4d29d5dbd5f..b49e3ab5730a 100644
> --- a/drivers/iio/proximity/as3935.c
> +++ b/drivers/iio/proximity/as3935.c
> @@ -224,10 +224,16 @@ static void as3935_event_work(struct work_struct *work)
>  {
>  	struct as3935_state *st;
>  	int val;
> +	int ret;
>  
>  	st = container_of(work, struct as3935_state, work.work);
>  
> -	as3935_read(st, AS3935_INT, &val);
> +	ret = as3935_read(st, AS3935_INT, &val);
> +	if (ret) {
> +		dev_warn(&st->spi->dev, "read error\n");

Maybe I'm misunderstanding the commit message, why does this error not
use dev_err()? A read error here would be rather serious, it might even
be worth it to return a code and fail through the caller too.

> +		return;
> +	}
> +
>  	val &= AS3935_INT_MASK;
>  
>  	switch (val) {
> @@ -235,7 +241,7 @@ static void as3935_event_work(struct work_struct *work)
>  		iio_trigger_poll(st->trig);
>  		break;
>  	case AS3935_NOISE_INT:
> -		dev_warn(&st->spi->dev, "noise level is too high");
> +		dev_warn(&st->spi->dev, "noise level is too high\n");
>  		break;
>  	}
>  }
> 

  parent reply	other threads:[~2016-05-31 14:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-30 14:52 [PATCH] iio: as3935: improve error reporting in as3935_event_work Arnd Bergmann
2016-05-30 17:33 ` Matt Ranostay
2016-05-31 14:53 ` Andrew F. Davis [this message]
2016-06-11 16:32   ` Jonathan Cameron
2016-06-12  6:55     ` Matt Ranostay
2016-06-26 16:05       ` 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=574DA582.50408@ti.com \
    --to=afd@ti.com \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=javier@osg.samsung.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