Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] soc_camera: fix compiler warning

media_build/v4l/soc_camera.c: In function 'soc_camera_host_register':
media_build/v4l/soc_camera.c:1513:10: warning: 'sasd' may be used uninitialized in this function [-Wmaybe-uninitialized]
snprintf(clk_name, sizeof(clk_name), "%d-%04x",
^
media_build/v4l/soc_camera.c:1464:34: note: 'sasd' was declared here
struct soc_camera_async_subdev *sasd;
^
By changing the type of 'i' to unsigned and changing a condition we finally
convince the compiler that sasd is really initialized.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
85e86c6e 73135e96

+3 -2
+3 -2
drivers/media/platform/soc_camera/soc_camera.c
··· 1466 1466 struct soc_camera_device *icd; 1467 1467 struct soc_camera_desc sdesc = {.host_desc.bus_id = ici->nr,}; 1468 1468 char clk_name[V4L2_SUBDEV_NAME_SIZE]; 1469 - int ret, i; 1469 + unsigned int i; 1470 + int ret; 1470 1471 1471 1472 /* First look for a sensor */ 1472 1473 for (i = 0; i < size; i++) { ··· 1476 1475 break; 1477 1476 } 1478 1477 1479 - if (i == size || asd[i]->match_type != V4L2_ASYNC_MATCH_I2C) { 1478 + if (i >= size || asd[i]->match_type != V4L2_ASYNC_MATCH_I2C) { 1480 1479 /* All useless */ 1481 1480 dev_err(ici->v4l2_dev.dev, "No I2C data source found!\n"); 1482 1481 return -ENODEV;