Skip to content

Commit a05e9aa

Browse files
Hans Verkuilmchehab
authored andcommitted
media: staging: media: atomisp: init high & low vars
Fix a compiler warning: include/linux/dev_printk.h: In function 'ov2680_probe': include/linux/dev_printk.h:144:31: warning: 'high' may be used uninitialized [-Wmaybe-uninitialized] 144 | dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__) | ^~~~~~~~ In function 'ov2680_detect', inlined from 'ov2680_s_config' at drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:468:8, inlined from 'ov2680_probe' at drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:647:8: drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:376:13: note: 'high' was declared here 376 | u32 high, low; | ^~~~ 'high' is indeed uninitialized after the ov_read_reg8() call failed, so there is no point showing the value. Just say that the read failed. But low can also be used uninitialized later, so just make it more robust and properly zero the high and low variables. Signed-off-by: Hans Verkuil <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 73af6c7 commit a05e9aa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/staging/media/atomisp/i2c/atomisp-ov2680.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ static int ov2680_get_fmt(struct v4l2_subdev *sd,
373373
static int ov2680_detect(struct i2c_client *client)
374374
{
375375
struct i2c_adapter *adapter = client->adapter;
376-
u32 high, low;
376+
u32 high = 0, low = 0;
377377
int ret;
378378
u16 id;
379379
u8 revision;
@@ -383,7 +383,7 @@ static int ov2680_detect(struct i2c_client *client)
383383

384384
ret = ov_read_reg8(client, OV2680_SC_CMMN_CHIP_ID_H, &high);
385385
if (ret) {
386-
dev_err(&client->dev, "sensor_id_high = 0x%x\n", high);
386+
dev_err(&client->dev, "sensor_id_high read failed (%d)\n", ret);
387387
return -ENODEV;
388388
}
389389
ret = ov_read_reg8(client, OV2680_SC_CMMN_CHIP_ID_L, &low);

0 commit comments

Comments
 (0)