aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andy.shevchenko@gmail.com>2017-06-13 05:22:22 -0400
committerJiri Kosina <jkosina@suse.cz>2017-06-13 08:29:20 -0400
commit08585e43d22802666a466af1ca5795085e74d60d (patch)
treecf43239899fe85d0e70dff3f3f24fe97276a1430
parent91b9ae48aadd7e634161372b0bc3ffc88a050e8b (diff)
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 <andy.shevchenko@gmail.com> Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/hid-core.c2
1 files changed, 1 insertions, 1 deletions
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)
1046 case 16: return ((__s16)value); 1046 case 16: return ((__s16)value);
1047 case 32: return ((__s32)value); 1047 case 32: return ((__s32)value);
1048 } 1048 }
1049 return value & (1 << (n - 1)) ? value | (-1 << n) : value; 1049 return value & (1 << (n - 1)) ? value | (~0U << n) : value;
1050} 1050}
1051 1051
1052s32 hid_snto32(__u32 value, unsigned n) 1052s32 hid_snto32(__u32 value, unsigned n)