]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
media: ov9650: avoid maybe-uninitialized warnings
authorArnd Bergmann <arnd@arndb.de>
Wed, 26 Sep 2018 12:51:01 +0000 (08:51 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Fri, 5 Oct 2018 15:04:39 +0000 (11:04 -0400)
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>
Reviewed-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/i2c/ov9650.c

index 3c9e6798d14b6f34031c926f130ad0df98b97d5b..f0587c0c0a7246547a5eb104c73df35dd21dff3b 100644 (file)
@@ -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);