Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 08585e43 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Jiri Kosina
Browse files

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: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 91b9ae48
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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)