From: Hans Verkuil <hverkuil@xs4all.nl> To: Arnd Bergmann <arnd@arndb.de>, linux-kernel@vger.kernel.org, Mauro Carvalho Chehab <mchehab@kernel.org> Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>, "Linus Torvalds" <torvalds@linux-foundation.org>, "Tejun Heo" <tj@kernel.org>, "Guenter Roeck" <linux@roeck-us.net>, linux-ide@vger.kernel.org, linux-media@vger.kernel.org, akpm@linux-foundation.org, dri-devel@lists.freedesktop.org, "Niklas Söderlund" <niklas.soderlund@ragnatech.se>, "Robert Jarzmik" <robert.jarzmik@free.fr>, "Daeseok Youn" <daeseok.youn@gmail.com>, "Alan Cox" <alan@linux.intel.com>, adi-buildroot-devel@lists.sourceforge.net, linux-renesas-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devel@driverdev.osuosl.org Subject: Re: [PATCH 14/14] [media] fix warning on v4l2_subdev_call() result interpreted as bool Date: Mon, 17 Jul 2017 15:45:08 +0200 [thread overview] Message-ID: <f57e08d9-0984-b67c-c64b-c7e0542d0361@xs4all.nl> (raw) In-Reply-To: <20170714093938.1469319-1-arnd@arndb.de> On 14/07/17 11:36, Arnd Bergmann wrote: > v4l2_subdev_call is a macro returning whatever the callback return > type is, usually 'int'. With gcc-7 and ccache, this can lead to > many wanings like: > > media/platform/pxa_camera.c: In function 'pxa_mbus_build_fmts_xlate': > media/platform/pxa_camera.c:766:27: error: ?: using integer constants in boolean context [-Werror=int-in-bool-context] > while (!v4l2_subdev_call(subdev, pad, enum_mbus_code, NULL, &code)) { > media/atomisp/pci/atomisp2/atomisp_cmd.c: In function 'atomisp_s_ae_window': > media/atomisp/pci/atomisp2/atomisp_cmd.c:6414:52: error: ?: using integer constants in boolean context [-Werror=int-in-bool-context] > if (v4l2_subdev_call(isp->inputs[asd->input_curr].camera, > > The best workaround I could come up with is to change all the > callers that use the return code from v4l2_subdev_call() in an > 'if' or 'while' condition. > > In case of simple 'if' checks, adding a temporary variable is > usually ok, and sometimes this can be used to propagate or > print an error code, so I do that. > > For the 'while' loops, I ended up adding an otherwise useless > comparison with zero, which unfortunately makes the code a little > uglied. > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > --- > drivers/media/pci/cx18/cx18-ioctl.c | 6 ++++-- > drivers/media/pci/saa7146/mxb.c | 5 +++-- > drivers/media/platform/atmel/atmel-isc.c | 4 ++-- > drivers/media/platform/atmel/atmel-isi.c | 4 ++-- > drivers/media/platform/blackfin/bfin_capture.c | 4 ++-- > drivers/media/platform/omap3isp/ispccdc.c | 5 +++-- > drivers/media/platform/pxa_camera.c | 3 ++- > drivers/media/platform/rcar-vin/rcar-core.c | 2 +- > drivers/media/platform/rcar-vin/rcar-dma.c | 4 +++- > drivers/media/platform/soc_camera/soc_camera.c | 4 ++-- > drivers/media/platform/stm32/stm32-dcmi.c | 4 ++-- > drivers/media/platform/ti-vpe/cal.c | 6 ++++-- > drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 13 +++++++------ > 13 files changed, 37 insertions(+), 27 deletions(-) > > diff --git a/drivers/media/pci/cx18/cx18-ioctl.c b/drivers/media/pci/cx18/cx18-ioctl.c > index 80b902b12a78..1803f28fc501 100644 > --- a/drivers/media/pci/cx18/cx18-ioctl.c > +++ b/drivers/media/pci/cx18/cx18-ioctl.c > @@ -188,6 +188,7 @@ static int cx18_g_fmt_sliced_vbi_cap(struct file *file, void *fh, > { > struct cx18 *cx = fh2id(fh)->cx; > struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; > + int ret; > > /* sane, V4L2 spec compliant, defaults */ > vbifmt->reserved[0] = 0; > @@ -201,8 +202,9 @@ static int cx18_g_fmt_sliced_vbi_cap(struct file *file, void *fh, > * digitizer/slicer. Note, cx18_av_vbi() wipes the passed in > * fmt->fmt.sliced under valid calling conditions > */ > - if (v4l2_subdev_call(cx->sd_av, vbi, g_sliced_fmt, &fmt->fmt.sliced)) > - return -EINVAL; > + ret = v4l2_subdev_call(cx->sd_av, vbi, g_sliced_fmt, &fmt->fmt.sliced); > + if (ret) > + return ret; Please keep the -EINVAL here. I can't be 100% certain that returning 'ret' wouldn't break something. > > vbifmt->service_set = cx18_get_service_set(vbifmt); > return 0; <snip> > diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c > index 97093baf28ac..fe56a037f065 100644 > --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c > +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c > @@ -6405,19 +6405,20 @@ int atomisp_s_ae_window(struct atomisp_sub_device *asd, > struct atomisp_device *isp = asd->isp; > /* Coverity CID 298071 - initialzize struct */ > struct v4l2_subdev_selection sel = { 0 }; > + int ret; > > sel.r.left = arg->x_left; > sel.r.top = arg->y_top; > sel.r.width = arg->x_right - arg->x_left + 1; > sel.r.height = arg->y_bottom - arg->y_top + 1; > > - if (v4l2_subdev_call(isp->inputs[asd->input_curr].camera, > - pad, set_selection, NULL, &sel)) { > - dev_err(isp->dev, "failed to call sensor set_selection.\n"); > - return -EINVAL; > - } > + ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera, > + pad, set_selection, NULL, &sel); > + if (ret) > + dev_err(isp->dev, "failed to call sensor set_selection: %d\n", > + ret); Same here: just keep the 'return -EINVAL'. > > - return 0; > + return ret; > } > > int atomisp_flash_enable(struct atomisp_sub_device *asd, int num_frames) > This is all very hackish, though. I'm not terribly keen on this patch. It's not clear to me *why* these warnings appear in your setup. Regards, Hans
WARNING: multiple messages have this Message-ID (diff)
From: hverkuil@xs4all.nl (Hans Verkuil) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 14/14] [media] fix warning on v4l2_subdev_call() result interpreted as bool Date: Mon, 17 Jul 2017 15:45:08 +0200 [thread overview] Message-ID: <f57e08d9-0984-b67c-c64b-c7e0542d0361@xs4all.nl> (raw) In-Reply-To: <20170714093938.1469319-1-arnd@arndb.de> On 14/07/17 11:36, Arnd Bergmann wrote: > v4l2_subdev_call is a macro returning whatever the callback return > type is, usually 'int'. With gcc-7 and ccache, this can lead to > many wanings like: > > media/platform/pxa_camera.c: In function 'pxa_mbus_build_fmts_xlate': > media/platform/pxa_camera.c:766:27: error: ?: using integer constants in boolean context [-Werror=int-in-bool-context] > while (!v4l2_subdev_call(subdev, pad, enum_mbus_code, NULL, &code)) { > media/atomisp/pci/atomisp2/atomisp_cmd.c: In function 'atomisp_s_ae_window': > media/atomisp/pci/atomisp2/atomisp_cmd.c:6414:52: error: ?: using integer constants in boolean context [-Werror=int-in-bool-context] > if (v4l2_subdev_call(isp->inputs[asd->input_curr].camera, > > The best workaround I could come up with is to change all the > callers that use the return code from v4l2_subdev_call() in an > 'if' or 'while' condition. > > In case of simple 'if' checks, adding a temporary variable is > usually ok, and sometimes this can be used to propagate or > print an error code, so I do that. > > For the 'while' loops, I ended up adding an otherwise useless > comparison with zero, which unfortunately makes the code a little > uglied. > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > --- > drivers/media/pci/cx18/cx18-ioctl.c | 6 ++++-- > drivers/media/pci/saa7146/mxb.c | 5 +++-- > drivers/media/platform/atmel/atmel-isc.c | 4 ++-- > drivers/media/platform/atmel/atmel-isi.c | 4 ++-- > drivers/media/platform/blackfin/bfin_capture.c | 4 ++-- > drivers/media/platform/omap3isp/ispccdc.c | 5 +++-- > drivers/media/platform/pxa_camera.c | 3 ++- > drivers/media/platform/rcar-vin/rcar-core.c | 2 +- > drivers/media/platform/rcar-vin/rcar-dma.c | 4 +++- > drivers/media/platform/soc_camera/soc_camera.c | 4 ++-- > drivers/media/platform/stm32/stm32-dcmi.c | 4 ++-- > drivers/media/platform/ti-vpe/cal.c | 6 ++++-- > drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 13 +++++++------ > 13 files changed, 37 insertions(+), 27 deletions(-) > > diff --git a/drivers/media/pci/cx18/cx18-ioctl.c b/drivers/media/pci/cx18/cx18-ioctl.c > index 80b902b12a78..1803f28fc501 100644 > --- a/drivers/media/pci/cx18/cx18-ioctl.c > +++ b/drivers/media/pci/cx18/cx18-ioctl.c > @@ -188,6 +188,7 @@ static int cx18_g_fmt_sliced_vbi_cap(struct file *file, void *fh, > { > struct cx18 *cx = fh2id(fh)->cx; > struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; > + int ret; > > /* sane, V4L2 spec compliant, defaults */ > vbifmt->reserved[0] = 0; > @@ -201,8 +202,9 @@ static int cx18_g_fmt_sliced_vbi_cap(struct file *file, void *fh, > * digitizer/slicer. Note, cx18_av_vbi() wipes the passed in > * fmt->fmt.sliced under valid calling conditions > */ > - if (v4l2_subdev_call(cx->sd_av, vbi, g_sliced_fmt, &fmt->fmt.sliced)) > - return -EINVAL; > + ret = v4l2_subdev_call(cx->sd_av, vbi, g_sliced_fmt, &fmt->fmt.sliced); > + if (ret) > + return ret; Please keep the -EINVAL here. I can't be 100% certain that returning 'ret' wouldn't break something. > > vbifmt->service_set = cx18_get_service_set(vbifmt); > return 0; <snip> > diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c > index 97093baf28ac..fe56a037f065 100644 > --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c > +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c > @@ -6405,19 +6405,20 @@ int atomisp_s_ae_window(struct atomisp_sub_device *asd, > struct atomisp_device *isp = asd->isp; > /* Coverity CID 298071 - initialzize struct */ > struct v4l2_subdev_selection sel = { 0 }; > + int ret; > > sel.r.left = arg->x_left; > sel.r.top = arg->y_top; > sel.r.width = arg->x_right - arg->x_left + 1; > sel.r.height = arg->y_bottom - arg->y_top + 1; > > - if (v4l2_subdev_call(isp->inputs[asd->input_curr].camera, > - pad, set_selection, NULL, &sel)) { > - dev_err(isp->dev, "failed to call sensor set_selection.\n"); > - return -EINVAL; > - } > + ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera, > + pad, set_selection, NULL, &sel); > + if (ret) > + dev_err(isp->dev, "failed to call sensor set_selection: %d\n", > + ret); Same here: just keep the 'return -EINVAL'. > > - return 0; > + return ret; > } > > int atomisp_flash_enable(struct atomisp_sub_device *asd, int num_frames) > This is all very hackish, though. I'm not terribly keen on this patch. It's not clear to me *why* these warnings appear in your setup. Regards, Hans
next prev parent reply other threads:[~2017-07-17 13:45 UTC|newest] Thread overview: 95+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-07-14 9:25 [PATCH 00/14] gcc-7 warnings Arnd Bergmann 2017-07-14 9:25 ` Arnd Bergmann 2017-07-14 9:25 ` [PATCH, RESEND 01/14] ide: avoid warning for timings calculation Arnd Bergmann 2017-07-14 9:25 ` Arnd Bergmann 2017-07-14 9:25 ` [PATCH, RESEND 02/14] ata: avoid gcc-7 warning in ata_timing_quantize Arnd Bergmann 2017-07-14 9:25 ` Arnd Bergmann 2017-07-15 10:56 ` Tejun Heo 2017-07-15 10:56 ` Tejun Heo 2017-07-14 9:25 ` [PATCH, RESEND 03/14] drm/vmwgfx: avoid gcc-7 parentheses warning Arnd Bergmann 2017-07-14 9:25 ` Arnd Bergmann 2017-07-14 10:11 ` Jani Nikula 2017-07-14 10:11 ` Jani Nikula 2017-07-14 19:21 ` Linus Torvalds 2017-07-14 19:21 ` Linus Torvalds 2017-07-14 19:23 ` Linus Torvalds 2017-07-14 20:28 ` Arnd Bergmann 2017-07-17 13:15 ` Sinclair Yeh 2017-07-17 13:15 ` Sinclair Yeh 2017-07-14 9:25 ` [PATCH 04/14] x86: math-emu: avoid -Wint-in-bool-context warning Arnd Bergmann 2017-07-14 9:25 ` Arnd Bergmann 2017-07-14 9:25 ` [PATCH 05/14] isdn: isdnloop: suppress a gcc-7 warning Arnd Bergmann 2017-07-14 9:25 ` Arnd Bergmann 2017-07-14 10:08 ` Joe Perches 2017-07-14 10:37 ` Arnd Bergmann 2017-07-15 4:20 ` Kevin Easton 2017-07-14 9:25 ` [PATCH 06/14] acpi: thermal: fix gcc-6/ccache warning Arnd Bergmann 2017-07-14 9:25 ` Arnd Bergmann 2017-07-14 9:25 ` [PATCH 07/14] proc/kcore: hide a harmless warning Arnd Bergmann 2017-07-14 9:25 ` Arnd Bergmann 2017-07-14 12:28 ` Ard Biesheuvel 2017-07-18 19:53 ` Arnd Bergmann 2017-07-18 19:53 ` Arnd Bergmann 2017-07-18 19:55 ` Ard Biesheuvel 2017-07-18 20:01 ` Arnd Bergmann 2017-07-18 20:07 ` Ard Biesheuvel 2017-07-18 20:21 ` Arnd Bergmann 2017-07-14 9:25 ` [PATCH 08/14] Input: adxl34x - fix gcc-7 -Wint-in-bool-context warning Arnd Bergmann 2017-07-14 9:25 ` Arnd Bergmann 2017-07-14 19:24 ` Linus Torvalds 2017-07-14 20:17 ` Arnd Bergmann 2017-07-14 21:40 ` Dmitry Torokhov 2017-07-14 9:30 ` [PATCH 09/14] SFI: fix tautological-compare warning Arnd Bergmann 2017-07-14 9:30 ` Arnd Bergmann 2017-07-14 9:31 ` [PATCH 10/14] staging:iio:resolver:ad2s1210 fix negative IIO_ANGL_VEL read Arnd Bergmann 2017-07-14 9:31 ` Arnd Bergmann 2017-07-15 11:42 ` Jonathan Cameron 2017-07-14 9:31 ` [PATCH 11/14] IB/uverbs: fix gcc-7 type warning Arnd Bergmann 2017-07-14 9:31 ` Arnd Bergmann 2017-07-14 9:46 ` Leon Romanovsky 2017-07-14 9:31 ` [PATCH 12/14] drm/nouveau/clk: fix gcc-7 -Wint-in-bool-context warning Arnd Bergmann 2017-07-14 9:31 ` Arnd Bergmann 2017-07-14 9:31 ` [PATCH 13/14] iopoll: avoid " Arnd Bergmann 2017-07-14 9:31 ` Arnd Bergmann 2017-07-14 9:55 ` Joe Perches 2017-07-14 10:22 ` Arnd Bergmann 2017-07-14 9:36 ` [PATCH 14/14] [media] fix warning on v4l2_subdev_call() result interpreted as bool Arnd Bergmann 2017-07-14 9:36 ` Arnd Bergmann 2017-07-14 9:36 ` Arnd Bergmann 2017-07-14 12:05 ` Dan Carpenter 2017-07-14 12:05 ` Dan Carpenter 2017-07-14 12:05 ` Dan Carpenter 2017-07-14 12:27 ` Arnd Bergmann 2017-07-14 12:27 ` Arnd Bergmann 2017-07-14 12:27 ` Arnd Bergmann 2017-07-14 12:55 ` Dan Carpenter 2017-07-14 12:55 ` Dan Carpenter 2017-07-14 12:55 ` Dan Carpenter 2017-07-14 13:09 ` Dan Carpenter 2017-07-14 13:09 ` Dan Carpenter 2017-07-14 13:09 ` Dan Carpenter 2017-07-14 19:32 ` Arnd Bergmann 2017-07-14 19:32 ` Arnd Bergmann 2017-07-14 19:32 ` Arnd Bergmann 2017-07-14 12:41 ` Dan Carpenter 2017-07-14 12:41 ` Dan Carpenter 2017-07-14 12:41 ` Dan Carpenter 2017-07-17 13:45 ` Hans Verkuil [this message] 2017-07-17 13:45 ` Hans Verkuil 2017-07-17 14:26 ` Arnd Bergmann 2017-07-17 14:26 ` Arnd Bergmann 2017-07-17 14:26 ` Arnd Bergmann 2017-07-17 14:28 ` Dan Carpenter 2017-07-17 14:28 ` Dan Carpenter 2017-07-17 14:28 ` Dan Carpenter 2017-07-17 14:32 ` Hans Verkuil 2017-07-17 14:32 ` Hans Verkuil 2017-07-17 14:32 ` Hans Verkuil 2017-07-17 14:35 ` Hans Verkuil 2017-07-17 14:35 ` Hans Verkuil 2017-07-17 14:35 ` Hans Verkuil 2017-07-17 21:23 ` Arnd Bergmann 2017-07-17 21:23 ` Arnd Bergmann 2017-07-17 21:23 ` Arnd Bergmann 2017-07-14 10:29 ` [PATCH 00/14] gcc-7 warnings Greg Kroah-Hartman 2017-07-14 10:29 ` Greg Kroah-Hartman
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=f57e08d9-0984-b67c-c64b-c7e0542d0361@xs4all.nl \ --to=hverkuil@xs4all.nl \ --cc=adi-buildroot-devel@lists.sourceforge.net \ --cc=akpm@linux-foundation.org \ --cc=alan@linux.intel.com \ --cc=arnd@arndb.de \ --cc=daeseok.youn@gmail.com \ --cc=devel@driverdev.osuosl.org \ --cc=dri-devel@lists.freedesktop.org \ --cc=gregkh@linuxfoundation.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-ide@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-media@vger.kernel.org \ --cc=linux-renesas-soc@vger.kernel.org \ --cc=linux@roeck-us.net \ --cc=mchehab@kernel.org \ --cc=niklas.soderlund@ragnatech.se \ --cc=robert.jarzmik@free.fr \ --cc=tj@kernel.org \ --cc=torvalds@linux-foundation.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.