From: Eugene Syromyatnikov Date: Wed, 14 Aug 2019 15:15:47 +0000 (+0200) Subject: v4l2: avoid shifting left a signed number by 31 bit X-Git-Tag: v5.3~46 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=91281fec7823f1cd3df3374fbcbd14af52a3fa1b;p=strace v4l2: avoid shifting left a signed number by 31 bit cppcheck warns about it with the following diagnostics: error[shiftTooManyBitsSigned]: Shifting signed 32-bit value by 31 bits is undefined behaviour * v4l2.c [!v4l2_fourcc_be] (v4l2_fourcc_be): Shift left 1U and not 1 in order to get 0x80000000. --- diff --git a/v4l2.c b/v4l2.c index 5da457c6..505e7b87 100644 --- a/v4l2.c +++ b/v4l2.c @@ -47,7 +47,7 @@ typedef struct v4l2_standard struct_v4l2_standard; /* v4l2_fourcc_be was added by Linux commit v3.18-rc1~101^2^2~127 */ #ifndef v4l2_fourcc_be -# 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)) #endif #define FMT_FRACT "%u/%u"