From 08585e43d22802666a466af1ca5795085e74d60d Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 13 Jun 2017 12:22:22 +0300 Subject: HID: core: don't use negative operands when shift The recent C standard in 6.5.7 paragraph 4 defines that operands for bitwise shift operators should be non-negative, otherwise it's an undefined behaviour. Signed-off-by: Andy Shevchenko Acked-by: Benjamin Tissoires Signed-off-by: Jiri Kosina --- drivers/hid/hid-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 37084b645785..8017de4e5c11 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1046,7 +1046,7 @@ static s32 snto32(__u32 value, unsigned n) case 16: return ((__s16)value); case 32: return ((__s32)value); } - return value & (1 << (n - 1)) ? value | (-1 << n) : value; + return value & (1 << (n - 1)) ? value | (~0U << n) : value; } s32 hid_snto32(__u32 value, unsigned n) -- cgit v1.2.3