media: videodev2.h: Fix shifting signed 32-bit value by 31 bits problem
authorShuah Khan <skhan@linuxfoundation.org>
Thu, 13 Jun 2019 00:56:52 +0000 (20:56 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Fri, 21 Jun 2019 20:45:59 +0000 (16:45 -0400)
Fix v4l2_fourcc define to use "U" cast to avoid shifting signed 32-bit
value by 31 bits problem. This isn't a problem for kernel builds with
gcc.

This could be problem since this header is part of public API which
could be included for builds using compilers that don't handle this
condition safely resulting in undefined behavior.

Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
include/uapi/linux/videodev2.h

index 1050a75..9d9705c 100644 (file)
@@ -80,7 +80,7 @@
 /*  Four-character-code (FOURCC) */
 #define v4l2_fourcc(a, b, c, d)\
        ((__u32)(a) | ((__u32)(b) << 8) | ((__u32)(c) << 16) | ((__u32)(d) << 24))
-#define v4l2_fourcc_be(a, b, c, d)     (v4l2_fourcc(a, b, c, d) | (1 << 31))
+#define v4l2_fourcc_be(a, b, c, d)     (v4l2_fourcc(a, b, c, d) | (1U << 31))
 
 /*
  *     E N U M S