1 From 49036d4ab54259a8fa8c1511a7024ed95d68037d Mon Sep 17 00:00:00 2001
2 From: Nathan Chancellor <nathan@kernel.org>
3 Date: Mon, 31 Jan 2022 17:50:43 -0700
4 Subject: [PATCH] media: i2c: ov9281: Initialize id_msb to zero in
5 ov9281_check_sensor_id()
9 drivers/media/i2c/ov9281.c:1132:6: warning: variable 'id_msb' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
12 drivers/media/i2c/ov9281.c:1135:9: note: uninitialized use occurs here
15 drivers/media/i2c/ov9281.c:1132:2: note: remove the 'if' if its condition is always true
18 drivers/media/i2c/ov9281.c:1127:20: note: initialize the variable 'id_msb' to silence this warning
24 If the first ov9281_read_reg() call fails, id_msb will be used
25 uninitialized. However, this warning does not actually matter in
26 practice because the value of id is not used when either call to
27 ov9281_read_reg() fails, as the boolean OR will short circuit due to the
28 ret condition being checked first. Regardless, it is not good to use
29 variables uninitialized so silence the warning by initializing id_msb to
30 0, as was done with id.
32 Fixes: 20855581e0eb ("media: i2c: ov9281: Read chip ID via 2 reads")
33 Signed-off-by: Nathan Chancellor <nathan@kernel.org>
35 drivers/media/i2c/ov9281.c | 2 +-
36 1 file changed, 1 insertion(+), 1 deletion(-)
38 --- a/drivers/media/i2c/ov9281.c
39 +++ b/drivers/media/i2c/ov9281.c
40 @@ -1124,7 +1124,7 @@ static int ov9281_check_sensor_id(struct
41 struct i2c_client *client)
43 struct device *dev = &ov9281->client->dev;
45 + u32 id = 0, id_msb = 0;
48 ret = ov9281_read_reg(client, OV9281_REG_CHIP_ID + 1,