lkml.org 
[lkml]   [2019]   [Jun]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/2] media: v4l2-core: Shifting signed 32-bit value by 31 bits error
From
Date
On 6/5/19 2:53 PM, Shuah Khan wrote:
> Fix the following cppcheck error:
>
> Checking drivers/media/v4l2-core/v4l2-ioctl.c ...
> [drivers/media/v4l2-core/v4l2-ioctl.c:1370]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
>
> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
> ---
> drivers/media/v4l2-core/v4l2-ioctl.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> index 6859bdac86fe..333e387bafeb 100644
> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> @@ -1364,7 +1364,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
> (char)((fmt->pixelformat >> 8) & 0x7f),
> (char)((fmt->pixelformat >> 16) & 0x7f),
> (char)((fmt->pixelformat >> 24) & 0x7f),
> - (fmt->pixelformat & (1 << 31)) ? "-BE" : "");
> + (fmt->pixelformat & BIT(31)) ? "-BE" : "");
> break;
> }
> }
>

If this builds, I guess #define BIT(x) got pulled in indirectly
since bits.h nor bitops.h is currently #included in that source file.

Documentation/process/submit-checklist.rst rule #1 says:
1) If you use a facility then #include the file that defines/declares
that facility. Don't depend on other header files pulling in ones
that you use.

Please add #include <linux/bits or bitops.h>

--
~Randy

\
 
 \ /
  Last update: 2019-06-06 05:23    [W:0.073 / U:0.932 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site