iio: stmpe-adc: avoid harmless clang warning

Message ID 20190322140906.319267-1-arnd@arndb.de
State New
Headers show
Series
  • iio: stmpe-adc: avoid harmless clang warning
Related show

Commit Message

Arnd Bergmann March 22, 2019, 2:08 p.m.
Clang points out a control flow bug, which happens to be harmless:

drivers/iio/adc/stmpe-adc.c:204:13: error: variable 'data' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

The warning is sensible here, so let's just avoid the case by
adding appropriate error handling.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 drivers/iio/adc/stmpe-adc.c | 2 ++
 1 file changed, 2 insertions(+)

-- 
2.20.0

Comments

Nathan Chancellor March 22, 2019, 2:58 p.m. | #1
On Fri, Mar 22, 2019 at 03:08:39PM +0100, Arnd Bergmann wrote:
> Clang points out a control flow bug, which happens to be harmless:

> 

> drivers/iio/adc/stmpe-adc.c:204:13: error: variable 'data' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

> 

> The warning is sensible here, so let's just avoid the case by

> adding appropriate error handling.

> 

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

> ---

>  drivers/iio/adc/stmpe-adc.c | 2 ++

>  1 file changed, 2 insertions(+)

> 

> diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c

> index 37f4b74a5d32..ed3817c5c896 100644

> --- a/drivers/iio/adc/stmpe-adc.c

> +++ b/drivers/iio/adc/stmpe-adc.c

> @@ -205,6 +205,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.20.0

> 


I sent a similar patch, which is sitting in Jonathan's testing branch:

https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?id=e15146e4d4349b3f309f5591ea8de8d24071265f

Nathan
Arnd Bergmann March 22, 2019, 3:09 p.m. | #2
On Fri, Mar 22, 2019 at 3:58 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>

> On Fri, Mar 22, 2019 at 03:08:39PM +0100, Arnd Bergmann wrote:

> > Clang points out a control flow bug, which happens to be harmless:

> >

> > drivers/iio/adc/stmpe-adc.c:204:13: error: variable 'data' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

> >

> > The warning is sensible here, so let's just avoid the case by

> > adding appropriate error handling.

> >

> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>

> > ---

> >  drivers/iio/adc/stmpe-adc.c | 2 ++

> >  1 file changed, 2 insertions(+)

> >

> > diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c

> > index 37f4b74a5d32..ed3817c5c896 100644

> > --- a/drivers/iio/adc/stmpe-adc.c

> > +++ b/drivers/iio/adc/stmpe-adc.c

> > @@ -205,6 +205,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.20.0

> >

>

> I sent a similar patch, which is sitting in Jonathan's testing branch:

>

> https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?id=e15146e4d4349b3f309f5591ea8de8d24071265f


Ok, sorry for the dup. Your seems to be better than mine, too.

      Arnd

Patch

diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c
index 37f4b74a5d32..ed3817c5c896 100644
--- a/drivers/iio/adc/stmpe-adc.c
+++ b/drivers/iio/adc/stmpe-adc.c
@@ -205,6 +205,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);