From fb787e7a7e18753b447a4bf3424661a5efb1e0d0 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 20 Sep 2017 13:19:36 +1000 Subject: [PATCH] touchpad: invert an if condition to allow for early return if (foo) { everything } changed to : if (!foo) return everything Signed-off-by: Peter Hutterer --- src/evdev-mt-touchpad.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index af3e8907..61d4474a 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -2076,22 +2076,23 @@ tp_pair_tablet_mode_switch(struct evdev_device *touchpad, if ((tablet_mode_switch->tags & EVDEV_TAG_TABLET_MODE_SWITCH) == 0) return; - if (tp->tablet_mode_switch.tablet_mode_switch == NULL) { - evdev_log_debug(touchpad, - "tablet_mode_switch: activated for %s<->%s\n", - touchpad->devname, - tablet_mode_switch->devname); + if (tp->tablet_mode_switch.tablet_mode_switch) + return; - libinput_device_add_event_listener(&tablet_mode_switch->base, - &tp->tablet_mode_switch.listener, - tp_switch_event, tp); - tp->tablet_mode_switch.tablet_mode_switch = tablet_mode_switch; + evdev_log_debug(touchpad, + "tablet_mode_switch: activated for %s<->%s\n", + touchpad->devname, + tablet_mode_switch->devname); - if (evdev_device_switch_get_state(tablet_mode_switch, - LIBINPUT_SWITCH_TABLET_MODE) - == LIBINPUT_SWITCH_STATE_ON) { - tp_suspend(tp, touchpad); - } + libinput_device_add_event_listener(&tablet_mode_switch->base, + &tp->tablet_mode_switch.listener, + tp_switch_event, tp); + tp->tablet_mode_switch.tablet_mode_switch = tablet_mode_switch; + + if (evdev_device_switch_get_state(tablet_mode_switch, + LIBINPUT_SWITCH_TABLET_MODE) + == LIBINPUT_SWITCH_STATE_ON) { + tp_suspend(tp, touchpad); } }