* [PATCH] soc_camera: fix compiler warning
@ 2013-07-25 12:40 Hans Verkuil
2013-07-26 11:26 ` Guennadi Liakhovetski
0 siblings, 1 reply; 4+ messages in thread
From: Hans Verkuil @ 2013-07-25 12:40 UTC (permalink / raw)
To: linux-media; +Cc: Guennadi Liakhovetski
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>
---
drivers/media/platform/soc_camera/soc_camera.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index 2dd0e52..ed7a99f 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1466,7 +1466,8 @@ static int scan_async_group(struct soc_camera_host *ici,
struct soc_camera_device *icd;
struct soc_camera_desc sdesc = {.host_desc.bus_id = ici->nr,};
char clk_name[V4L2_SUBDEV_NAME_SIZE];
- int ret, i;
+ unsigned int i;
+ int ret;
/* First look for a sensor */
for (i = 0; i < size; i++) {
@@ -1475,7 +1476,7 @@ static int scan_async_group(struct soc_camera_host *ici,
break;
}
- if (i == size || asd[i]->bus_type != V4L2_ASYNC_BUS_I2C) {
+ if (i >= size || asd[i]->bus_type != V4L2_ASYNC_BUS_I2C) {
/* All useless */
dev_err(ici->v4l2_dev.dev, "No I2C data source found!\n");
return -ENODEV;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] soc_camera: fix compiler warning 2013-07-25 12:40 [PATCH] soc_camera: fix compiler warning Hans Verkuil @ 2013-07-26 11:26 ` Guennadi Liakhovetski 2013-07-26 12:01 ` Hans Verkuil 0 siblings, 1 reply; 4+ messages in thread From: Guennadi Liakhovetski @ 2013-07-26 11:26 UTC (permalink / raw) To: Hans Verkuil; +Cc: linux-media Hi Hans Thanks for the patch. On Thu, 25 Jul 2013, Hans Verkuil wrote: > > 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; > ^ Heh, cool... You did report a similar warning earlier, for which I cooked up a patch "[media] V4L2: soc-camera: fix uninitialised use compiler warning" and IIRC you reported that with that patch the warning disappeared... How come we've got another one now? Have you updated your compiler again or what can be the reason? In principle I have nothing against this patch, just wondering where you're getting your compilers from ;-) > 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> I haven't got any more 3.11 fixed in my queue and we have to push this before -rc3 / rc4 ;) So, if you prefer, feel free to take it via your tree with my Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Thanks Guennadi > --- > drivers/media/platform/soc_camera/soc_camera.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c > index 2dd0e52..ed7a99f 100644 > --- a/drivers/media/platform/soc_camera/soc_camera.c > +++ b/drivers/media/platform/soc_camera/soc_camera.c > @@ -1466,7 +1466,8 @@ static int scan_async_group(struct soc_camera_host *ici, > struct soc_camera_device *icd; > struct soc_camera_desc sdesc = {.host_desc.bus_id = ici->nr,}; > char clk_name[V4L2_SUBDEV_NAME_SIZE]; > - int ret, i; > + unsigned int i; > + int ret; > > /* First look for a sensor */ > for (i = 0; i < size; i++) { > @@ -1475,7 +1476,7 @@ static int scan_async_group(struct soc_camera_host *ici, > break; > } > > - if (i == size || asd[i]->bus_type != V4L2_ASYNC_BUS_I2C) { > + if (i >= size || asd[i]->bus_type != V4L2_ASYNC_BUS_I2C) { > /* All useless */ > dev_err(ici->v4l2_dev.dev, "No I2C data source found!\n"); > return -ENODEV; > -- > 1.8.3.2 > --- Guennadi Liakhovetski, Ph.D. Freelance Open-Source Software Developer http://www.open-technology.de/ ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] soc_camera: fix compiler warning 2013-07-26 11:26 ` Guennadi Liakhovetski @ 2013-07-26 12:01 ` Hans Verkuil 2013-07-26 12:08 ` Guennadi Liakhovetski 0 siblings, 1 reply; 4+ messages in thread From: Hans Verkuil @ 2013-07-26 12:01 UTC (permalink / raw) To: Guennadi Liakhovetski; +Cc: linux-media Hi Guennadi, On 07/26/2013 01:26 PM, Guennadi Liakhovetski wrote: > Hi Hans > > Thanks for the patch. > > On Thu, 25 Jul 2013, Hans Verkuil wrote: > >> >> 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; >> ^ > > Heh, cool... You did report a similar warning earlier, for which I cooked > up a patch "[media] V4L2: soc-camera: fix uninitialised use compiler > warning" and IIRC you reported that with that patch the warning > disappeared... How come we've got another one now? Have you updated your > compiler again or what can be the reason? It worked, but only for i686. The x86_64 compiler (exactly the same gcc version BTW) still couldn't understand that it really was initialized. See the build logs from the past few weeks. > In principle I have nothing against this patch, just wondering where > you're getting your compilers from ;-) Well, the compiler is just downloaded from gnu.org and regularly updated when a new version is released. The problem is not with the current git build, but with the compatibility builds. As far as I can tell different kernel versions may turn on or off different compiler warnings, so compiling for different kernels gives different results. >> 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> > > I haven't got any more 3.11 fixed in my queue and we have to push this > before -rc3 / rc4 ;) So, if you prefer, feel free to take it via your tree > with my > > Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> This is just for 3.12, there is no need to go to 3.11 for this since the warning doesn't appear when compiling 3.11. Do you still want me to take it, or do you prefer to queue it for 3.12 yourself? For the record, I expect to post a pull request for 3.12 today or Monday at the latest, so it's no problem for me. Hans > > Thanks > Guennadi > >> --- >> drivers/media/platform/soc_camera/soc_camera.c | 5 +++-- >> 1 file changed, 3 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c >> index 2dd0e52..ed7a99f 100644 >> --- a/drivers/media/platform/soc_camera/soc_camera.c >> +++ b/drivers/media/platform/soc_camera/soc_camera.c >> @@ -1466,7 +1466,8 @@ static int scan_async_group(struct soc_camera_host *ici, >> struct soc_camera_device *icd; >> struct soc_camera_desc sdesc = {.host_desc.bus_id = ici->nr,}; >> char clk_name[V4L2_SUBDEV_NAME_SIZE]; >> - int ret, i; >> + unsigned int i; >> + int ret; >> >> /* First look for a sensor */ >> for (i = 0; i < size; i++) { >> @@ -1475,7 +1476,7 @@ static int scan_async_group(struct soc_camera_host *ici, >> break; >> } >> >> - if (i == size || asd[i]->bus_type != V4L2_ASYNC_BUS_I2C) { >> + if (i >= size || asd[i]->bus_type != V4L2_ASYNC_BUS_I2C) { >> /* All useless */ >> dev_err(ici->v4l2_dev.dev, "No I2C data source found!\n"); >> return -ENODEV; >> -- >> 1.8.3.2 >> > > --- > Guennadi Liakhovetski, Ph.D. > Freelance Open-Source Software Developer > http://www.open-technology.de/ > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] soc_camera: fix compiler warning 2013-07-26 12:01 ` Hans Verkuil @ 2013-07-26 12:08 ` Guennadi Liakhovetski 0 siblings, 0 replies; 4+ messages in thread From: Guennadi Liakhovetski @ 2013-07-26 12:08 UTC (permalink / raw) To: Hans Verkuil; +Cc: linux-media On Fri, 26 Jul 2013, Hans Verkuil wrote: > Hi Guennadi, > > On 07/26/2013 01:26 PM, Guennadi Liakhovetski wrote: > > Hi Hans > > > > Thanks for the patch. > > > > On Thu, 25 Jul 2013, Hans Verkuil wrote: > > > >> > >> 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; > >> ^ > > > > Heh, cool... You did report a similar warning earlier, for which I cooked > > up a patch "[media] V4L2: soc-camera: fix uninitialised use compiler > > warning" and IIRC you reported that with that patch the warning > > disappeared... How come we've got another one now? Have you updated your > > compiler again or what can be the reason? > > It worked, but only for i686. The x86_64 compiler (exactly the same gcc version > BTW) still couldn't understand that it really was initialized. See the build > logs from the past few weeks. > > > In principle I have nothing against this patch, just wondering where > > you're getting your compilers from ;-) > > Well, the compiler is just downloaded from gnu.org and regularly updated when > a new version is released. > > The problem is not with the current git build, but with the compatibility builds. > As far as I can tell different kernel versions may turn on or off different > compiler warnings, so compiling for different kernels gives different results. Ok, good... > >> 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> > > > > I haven't got any more 3.11 fixed in my queue and we have to push this > > before -rc3 / rc4 ;) So, if you prefer, feel free to take it via your tree > > with my > > > > Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> > > This is just for 3.12, there is no need to go to 3.11 for this since the warning > doesn't appear when compiling 3.11. > > Do you still want me to take it, or do you prefer to queue it for 3.12 yourself? > For the record, I expect to post a pull request for 3.12 today or Monday at the > latest, so it's no problem for me. I'll take it then Thanks Guennadi > Hans > > > > > Thanks > > Guennadi > > > >> --- > >> drivers/media/platform/soc_camera/soc_camera.c | 5 +++-- > >> 1 file changed, 3 insertions(+), 2 deletions(-) > >> > >> diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c > >> index 2dd0e52..ed7a99f 100644 > >> --- a/drivers/media/platform/soc_camera/soc_camera.c > >> +++ b/drivers/media/platform/soc_camera/soc_camera.c > >> @@ -1466,7 +1466,8 @@ static int scan_async_group(struct soc_camera_host *ici, > >> struct soc_camera_device *icd; > >> struct soc_camera_desc sdesc = {.host_desc.bus_id = ici->nr,}; > >> char clk_name[V4L2_SUBDEV_NAME_SIZE]; > >> - int ret, i; > >> + unsigned int i; > >> + int ret; > >> > >> /* First look for a sensor */ > >> for (i = 0; i < size; i++) { > >> @@ -1475,7 +1476,7 @@ static int scan_async_group(struct soc_camera_host *ici, > >> break; > >> } > >> > >> - if (i == size || asd[i]->bus_type != V4L2_ASYNC_BUS_I2C) { > >> + if (i >= size || asd[i]->bus_type != V4L2_ASYNC_BUS_I2C) { > >> /* All useless */ > >> dev_err(ici->v4l2_dev.dev, "No I2C data source found!\n"); > >> return -ENODEV; > >> -- > >> 1.8.3.2 --- Guennadi Liakhovetski, Ph.D. Freelance Open-Source Software Developer http://www.open-technology.de/ ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-07-26 12:09 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-07-25 12:40 [PATCH] soc_camera: fix compiler warning Hans Verkuil 2013-07-26 11:26 ` Guennadi Liakhovetski 2013-07-26 12:01 ` Hans Verkuil 2013-07-26 12:08 ` Guennadi Liakhovetski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox