Skip to content

Commit

Permalink
media: videodev2.h: Fix shifting signed 32-bit value by 31 bits problem
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
shuahkh authored and mchehab committed Jun 21, 2019
1 parent 5ca004d commit ff3c65c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/uapi/linux/videodev2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ff3c65c

Please sign in to comment.