LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] media: omap3isp: fix out-of-range warning
@ 2021-11-24 19:24 Arnd Bergmann
  2021-11-24 22:26 ` Laurent Pinchart
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2021-11-24 19:24 UTC (permalink / raw)
  To: Laurent Pinchart, Mauro Carvalho Chehab
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers, Sakari Ailus,
	Vaibhav Hiremath, Stanimir Varbanov, Dominic Curran, David Cohen,
	linux-media, linux-kernel, llvm

From: Arnd Bergmann <arnd@arndb.de>

clang points out that the 8-bit height/width values never exceed
the range of that type when building with 'make W=1 LLVM=1':

drivers/media/platform/omap3isp/isph3a_af.c:173:6: error: result of comparison of constant 256 with expression of type '__u8' (aka 'unsigned char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
        if (IS_OUT_OF_BOUNDS(paxel_cfg->height, OMAP3ISP_AF_PAXEL_HEIGHT_MIN,
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/platform/omap3isp/isph3a_af.c:24:33: note: expanded from macro 'IS_OUT_OF_BOUNDS'
        (((value) < (min)) || ((value) > (max)))
                               ~~~~~~~ ^ ~~~~~
drivers/media/platform/omap3isp/isph3a_af.c:179:6: error: result of comparison of constant 256 with expression of type '__u8' (aka 'unsigned char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
        if (IS_OUT_OF_BOUNDS(paxel_cfg->width, OMAP3ISP_AF_PAXEL_WIDTH_MIN,
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/platform/omap3isp/isph3a_af.c:24:33: note: expanded from macro 'IS_OUT_OF_BOUNDS'
        (((value) < (min)) || ((value) > (max)))
                               ~~~~~~~ ^ ~~~~~

Add a cast to 32-bit to avoid the warning. Checking just the lower bounds
would be sufficient as well, but it seems more consistent to use
the IS_OUT_OF_BOUNDS() check for all members.

Fixes: 68e342b3068c ("[media] omap3isp: Statistics")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/media/platform/omap3isp/isph3a_af.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/omap3isp/isph3a_af.c b/drivers/media/platform/omap3isp/isph3a_af.c
index a65cfdfa9637..c544d9c812b0 100644
--- a/drivers/media/platform/omap3isp/isph3a_af.c
+++ b/drivers/media/platform/omap3isp/isph3a_af.c
@@ -170,13 +170,13 @@ static int h3a_af_validate_params(struct ispstat *af, void *new_conf)
 			     OMAP3ISP_AF_PAXEL_VERTICAL_COUNT_MAX))
 		return -EINVAL;
 
-	if (IS_OUT_OF_BOUNDS(paxel_cfg->height, OMAP3ISP_AF_PAXEL_HEIGHT_MIN,
+	if (IS_OUT_OF_BOUNDS((u32)paxel_cfg->height, OMAP3ISP_AF_PAXEL_HEIGHT_MIN,
 			     OMAP3ISP_AF_PAXEL_HEIGHT_MAX) ||
 	    paxel_cfg->height % 2)
 		return -EINVAL;
 
 	/* Check width */
-	if (IS_OUT_OF_BOUNDS(paxel_cfg->width, OMAP3ISP_AF_PAXEL_WIDTH_MIN,
+	if (IS_OUT_OF_BOUNDS((u32)paxel_cfg->width, OMAP3ISP_AF_PAXEL_WIDTH_MIN,
 			     OMAP3ISP_AF_PAXEL_WIDTH_MAX) ||
 	    paxel_cfg->width % 2)
 		return -EINVAL;
-- 
2.29.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: omap3isp: fix out-of-range warning
  2021-11-24 19:24 [PATCH] media: omap3isp: fix out-of-range warning Arnd Bergmann
@ 2021-11-24 22:26 ` Laurent Pinchart
  2021-11-25  7:43   ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: Laurent Pinchart @ 2021-11-24 22:26 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Mauro Carvalho Chehab, Arnd Bergmann, Nathan Chancellor,
	Nick Desaulniers, Sakari Ailus, Vaibhav Hiremath,
	Stanimir Varbanov, Dominic Curran, David Cohen, linux-media,
	linux-kernel, llvm

Hi Arnd,

Thank you for the patch.

On Wed, Nov 24, 2021 at 08:24:15PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> clang points out that the 8-bit height/width values never exceed
> the range of that type when building with 'make W=1 LLVM=1':
> 
> drivers/media/platform/omap3isp/isph3a_af.c:173:6: error: result of comparison of constant 256 with expression of type '__u8' (aka 'unsigned char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
>         if (IS_OUT_OF_BOUNDS(paxel_cfg->height, OMAP3ISP_AF_PAXEL_HEIGHT_MIN,
>             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/media/platform/omap3isp/isph3a_af.c:24:33: note: expanded from macro 'IS_OUT_OF_BOUNDS'
>         (((value) < (min)) || ((value) > (max)))
>                                ~~~~~~~ ^ ~~~~~
> drivers/media/platform/omap3isp/isph3a_af.c:179:6: error: result of comparison of constant 256 with expression of type '__u8' (aka 'unsigned char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
>         if (IS_OUT_OF_BOUNDS(paxel_cfg->width, OMAP3ISP_AF_PAXEL_WIDTH_MIN,
>             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/media/platform/omap3isp/isph3a_af.c:24:33: note: expanded from macro 'IS_OUT_OF_BOUNDS'
>         (((value) < (min)) || ((value) > (max)))
>                                ~~~~~~~ ^ ~~~~~
> 
> Add a cast to 32-bit to avoid the warning. Checking just the lower bounds
> would be sufficient as well, but it seems more consistent to use
> the IS_OUT_OF_BOUNDS() check for all members.

Mauro has submitted a fix that handles the cast in the
IS_OUT_OF_BOUNDS() macro, see
https://lore.kernel.org/all/b70f819b11e024649f113be1158f34b24914a1ed.1637573097.git.mchehab+huawei@kernel.org/.

> Fixes: 68e342b3068c ("[media] omap3isp: Statistics")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/media/platform/omap3isp/isph3a_af.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/omap3isp/isph3a_af.c b/drivers/media/platform/omap3isp/isph3a_af.c
> index a65cfdfa9637..c544d9c812b0 100644
> --- a/drivers/media/platform/omap3isp/isph3a_af.c
> +++ b/drivers/media/platform/omap3isp/isph3a_af.c
> @@ -170,13 +170,13 @@ static int h3a_af_validate_params(struct ispstat *af, void *new_conf)
>  			     OMAP3ISP_AF_PAXEL_VERTICAL_COUNT_MAX))
>  		return -EINVAL;
>  
> -	if (IS_OUT_OF_BOUNDS(paxel_cfg->height, OMAP3ISP_AF_PAXEL_HEIGHT_MIN,
> +	if (IS_OUT_OF_BOUNDS((u32)paxel_cfg->height, OMAP3ISP_AF_PAXEL_HEIGHT_MIN,
>  			     OMAP3ISP_AF_PAXEL_HEIGHT_MAX) ||
>  	    paxel_cfg->height % 2)
>  		return -EINVAL;
>  
>  	/* Check width */
> -	if (IS_OUT_OF_BOUNDS(paxel_cfg->width, OMAP3ISP_AF_PAXEL_WIDTH_MIN,
> +	if (IS_OUT_OF_BOUNDS((u32)paxel_cfg->width, OMAP3ISP_AF_PAXEL_WIDTH_MIN,
>  			     OMAP3ISP_AF_PAXEL_WIDTH_MAX) ||
>  	    paxel_cfg->width % 2)
>  		return -EINVAL;

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: omap3isp: fix out-of-range warning
  2021-11-24 22:26 ` Laurent Pinchart
@ 2021-11-25  7:43   ` Arnd Bergmann
  0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2021-11-25  7:43 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Mauro Carvalho Chehab, Arnd Bergmann, Nathan Chancellor,
	Nick Desaulniers, Sakari Ailus, Vaibhav Hiremath,
	Stanimir Varbanov, Dominic Curran, David Cohen,
	Linux Media Mailing List, Linux Kernel Mailing List, llvm

On Wed, Nov 24, 2021 at 11:26 PM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> On Wed, Nov 24, 2021 at 08:24:15PM +0100, Arnd Bergmann wrote:
> >
> > Add a cast to 32-bit to avoid the warning. Checking just the lower bounds
> > would be sufficient as well, but it seems more consistent to use
> > the IS_OUT_OF_BOUNDS() check for all members.
>
> Mauro has submitted a fix that handles the cast in the
> IS_OUT_OF_BOUNDS() macro, see
> https://lore.kernel.org/all/b70f819b11e024649f113be1158f34b24914a1ed.1637573097.git.mchehab+huawei@kernel.org/.

Ok, thanks. I've marked my patch as 'Obsoleted' in patchwork now.

      Arnd

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-25  7:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24 19:24 [PATCH] media: omap3isp: fix out-of-range warning Arnd Bergmann
2021-11-24 22:26 ` Laurent Pinchart
2021-11-25  7:43   ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).