From c13567bb68da8ff224c3839525fea800a9dd6db4 Mon Sep 17 00:00:00 2001 From: Jason Gerecke Date: Wed, 10 Apr 2019 09:55:25 -0700 Subject: [PATCH] fallback: Fix ubsan runtime error Running libinput-test-suite with -fsanitize=undefined highlights the two following errors. Force C to realize we want an unsigned result by making the '1' literal unsigned. ../src/evdev-fallback.c:314:22 runtime error: left shift of 1 by 31 places cannot be represented in type 'int' ../src/evdev-fallback.c:377:24 runtime error: left shift of 1 by 31 places cannot be represented in type 'int' v2: use bit() instead of manual shift 1U<<1 Signed-off-by: Peter Hutterer (cherry picked from commit f589f4968fc0f08590655f69dc518c080df16be7) --- src/evdev-fallback.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/evdev-fallback.c b/src/evdev-fallback.c index a25f8b49..e5169c48 100644 --- a/src/evdev-fallback.c +++ b/src/evdev-fallback.c @@ -311,7 +311,7 @@ fallback_flush_mt_down(struct fallback_dispatch *dispatch, if (seat_slot == -1) return false; - seat->slot_map |= 1 << seat_slot; + seat->slot_map |= bit(seat_slot); point = slot->point; slot->hysteresis_center = point; evdev_transform_absolute(device, &point); @@ -374,7 +374,7 @@ fallback_flush_mt_up(struct fallback_dispatch *dispatch, if (seat_slot == -1) return false; - seat->slot_map &= ~(1 << seat_slot); + seat->slot_map &= ~bit(seat_slot); touch_notify_touch_up(base, time, slot_idx, seat_slot); @@ -402,7 +402,7 @@ fallback_flush_mt_cancel(struct fallback_dispatch *dispatch, if (seat_slot == -1) return false; - seat->slot_map &= ~(1 << seat_slot); + seat->slot_map &= ~bit(seat_slot); touch_notify_touch_cancel(base, time, slot_idx, seat_slot); @@ -434,7 +434,7 @@ fallback_flush_st_down(struct fallback_dispatch *dispatch, if (seat_slot == -1) return false; - seat->slot_map |= 1 << seat_slot; + seat->slot_map |= bit(seat_slot); point = dispatch->abs.point; evdev_transform_absolute(device, &point); @@ -484,7 +484,7 @@ fallback_flush_st_up(struct fallback_dispatch *dispatch, if (seat_slot == -1) return false; - seat->slot_map &= ~(1 << seat_slot); + seat->slot_map &= ~bit(seat_slot); touch_notify_touch_up(base, time, -1, seat_slot); @@ -509,7 +509,7 @@ fallback_flush_st_cancel(struct fallback_dispatch *dispatch, if (seat_slot == -1) return false; - seat->slot_map &= ~(1 << seat_slot); + seat->slot_map &= ~bit(seat_slot); touch_notify_touch_cancel(base, time, -1, seat_slot);