All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: ov9650: avoid maybe-uninitialized warnings
@ 2018-09-26 12:51 Arnd Bergmann
  2018-09-26 15:49 ` Akinobu Mita
  2018-09-26 21:17 ` Sakari Ailus
  0 siblings, 2 replies; 4+ messages in thread
From: Arnd Bergmann @ 2018-09-26 12:51 UTC (permalink / raw)
  To: Sakari Ailus, Mauro Carvalho Chehab
  Cc: Arnd Bergmann, Akinobu Mita, Sylwester Nawrocki, Hans Verkuil,
	Wolfram Sang, Gustavo A. R. Silva, linux-media, linux-kernel

The regmap change causes multiple warnings like

drivers/media/i2c/ov9650.c: In function 'ov965x_g_volatile_ctrl':
drivers/media/i2c/ov9650.c:889:29: error: 'reg2' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   exposure = ((reg2 & 0x3f) << 10) | (reg1 << 2) |
              ~~~~~~~~~~~~~~~^~~~~~

It is apparently hard for the compiler to see here if ov965x_read()
returned successfully or not. Besides, we have a v4l2_dbg() statement
that prints an uninitialized value if regmap_read() fails.

Adding an 'else' clause avoids the ambiguity.

Fixes: 361f3803adfe ("media: ov9650: use SCCB regmap")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/media/i2c/ov9650.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
index 3c9e6798d14b..77944da31de1 100644
--- a/drivers/media/i2c/ov9650.c
+++ b/drivers/media/i2c/ov9650.c
@@ -433,6 +433,8 @@ static int ov965x_read(struct ov965x *ov965x, u8 addr, u8 *val)
 	ret = regmap_read(ov965x->regmap, addr, &buf);
 	if (!ret)
 		*val = buf;
+        else
+                *val = -1;
 
 	v4l2_dbg(2, debug, &ov965x->sd, "%s: 0x%02x @ 0x%02x. (%d)\n",
 		 __func__, *val, addr, ret);
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: ov9650: avoid maybe-uninitialized warnings
  2018-09-26 12:51 [PATCH] media: ov9650: avoid maybe-uninitialized warnings Arnd Bergmann
@ 2018-09-26 15:49 ` Akinobu Mita
  2018-09-26 21:17 ` Sakari Ailus
  1 sibling, 0 replies; 4+ messages in thread
From: Akinobu Mita @ 2018-09-26 15:49 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Sakari Ailus, Mauro Carvalho Chehab, Sylwester Nawrocki,
	Hans Verkuil, wsa+renesas, gustavo, linux-media, LKML

2018年9月26日(水) 21:51 Arnd Bergmann <arnd@arndb.de>:
>
> The regmap change causes multiple warnings like
>
> drivers/media/i2c/ov9650.c: In function 'ov965x_g_volatile_ctrl':
> drivers/media/i2c/ov9650.c:889:29: error: 'reg2' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>    exposure = ((reg2 & 0x3f) << 10) | (reg1 << 2) |
>               ~~~~~~~~~~~~~~~^~~~~~
>
> It is apparently hard for the compiler to see here if ov965x_read()
> returned successfully or not. Besides, we have a v4l2_dbg() statement
> that prints an uninitialized value if regmap_read() fails.
>
> Adding an 'else' clause avoids the ambiguity.
>
> Fixes: 361f3803adfe ("media: ov9650: use SCCB regmap")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Looks good.

Reviewed-by: Akinobu Mita <akinobu.mita@gmail.com>

> ---
>  drivers/media/i2c/ov9650.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
> index 3c9e6798d14b..77944da31de1 100644
> --- a/drivers/media/i2c/ov9650.c
> +++ b/drivers/media/i2c/ov9650.c
> @@ -433,6 +433,8 @@ static int ov965x_read(struct ov965x *ov965x, u8 addr, u8 *val)
>         ret = regmap_read(ov965x->regmap, addr, &buf);
>         if (!ret)
>                 *val = buf;
> +        else
> +                *val = -1;
>
>         v4l2_dbg(2, debug, &ov965x->sd, "%s: 0x%02x @ 0x%02x. (%d)\n",
>                  __func__, *val, addr, ret);
> --
> 2.18.0
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: ov9650: avoid maybe-uninitialized warnings
  2018-09-26 12:51 [PATCH] media: ov9650: avoid maybe-uninitialized warnings Arnd Bergmann
  2018-09-26 15:49 ` Akinobu Mita
@ 2018-09-26 21:17 ` Sakari Ailus
  2018-09-27  9:06   ` Arnd Bergmann
  1 sibling, 1 reply; 4+ messages in thread
From: Sakari Ailus @ 2018-09-26 21:17 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Mauro Carvalho Chehab, Akinobu Mita, Sylwester Nawrocki,
	Hans Verkuil, Wolfram Sang, Gustavo A. R. Silva, linux-media,
	linux-kernel

Hi Arnd,

On Wed, Sep 26, 2018 at 02:51:01PM +0200, Arnd Bergmann wrote:
> The regmap change causes multiple warnings like
> 
> drivers/media/i2c/ov9650.c: In function 'ov965x_g_volatile_ctrl':
> drivers/media/i2c/ov9650.c:889:29: error: 'reg2' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>    exposure = ((reg2 & 0x3f) << 10) | (reg1 << 2) |
>               ~~~~~~~~~~~~~~~^~~~~~
> 
> It is apparently hard for the compiler to see here if ov965x_read()
> returned successfully or not. Besides, we have a v4l2_dbg() statement
> that prints an uninitialized value if regmap_read() fails.
> 
> Adding an 'else' clause avoids the ambiguity.

Thanks!

I'm not sure what happened here but the two lines use spaces for
indentation. I've replaced those with tabs.

> 
> Fixes: 361f3803adfe ("media: ov9650: use SCCB regmap")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/media/i2c/ov9650.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
> index 3c9e6798d14b..77944da31de1 100644
> --- a/drivers/media/i2c/ov9650.c
> +++ b/drivers/media/i2c/ov9650.c
> @@ -433,6 +433,8 @@ static int ov965x_read(struct ov965x *ov965x, u8 addr, u8 *val)
>  	ret = regmap_read(ov965x->regmap, addr, &buf);
>  	if (!ret)
>  		*val = buf;
> +        else
> +                *val = -1;
>  
>  	v4l2_dbg(2, debug, &ov965x->sd, "%s: 0x%02x @ 0x%02x. (%d)\n",
>  		 __func__, *val, addr, ret);

-- 
Kind regards,

Sakari Ailus
sakari.ailus@linux.intel.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: ov9650: avoid maybe-uninitialized warnings
  2018-09-26 21:17 ` Sakari Ailus
@ 2018-09-27  9:06   ` Arnd Bergmann
  0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2018-09-27  9:06 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Mauro Carvalho Chehab, Akinobu Mita, Sylwester Nawrocki,
	Hans Verkuil, Wolfram Sang, Gustavo A. R. Silva,
	Linux Media Mailing List, Linux Kernel Mailing List

On Wed, Sep 26, 2018 at 11:17 PM Sakari Ailus
<sakari.ailus@linux.intel.com> wrote:
>
> Hi Arnd,
>
> On Wed, Sep 26, 2018 at 02:51:01PM +0200, Arnd Bergmann wrote:
> > The regmap change causes multiple warnings like
> >
> > drivers/media/i2c/ov9650.c: In function 'ov965x_g_volatile_ctrl':
> > drivers/media/i2c/ov9650.c:889:29: error: 'reg2' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> >    exposure = ((reg2 & 0x3f) << 10) | (reg1 << 2) |
> >               ~~~~~~~~~~~~~~~^~~~~~
> >
> > It is apparently hard for the compiler to see here if ov965x_read()
> > returned successfully or not. Besides, we have a v4l2_dbg() statement
> > that prints an uninitialized value if regmap_read() fails.
> >
> > Adding an 'else' clause avoids the ambiguity.
>
> Thanks!
>
> I'm not sure what happened here but the two lines use spaces for
> indentation. I've replaced those with tabs.

Thanks a lot, that was clearly what I had intended to send.

        Arnd

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-09-27  9:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-26 12:51 [PATCH] media: ov9650: avoid maybe-uninitialized warnings Arnd Bergmann
2018-09-26 15:49 ` Akinobu Mita
2018-09-26 21:17 ` Sakari Ailus
2018-09-27  9:06   ` Arnd Bergmann

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.