mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-03 20:30:27 +01:00
[clang-tidy] do not use else after return
Found with readability-else-after-return Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
cd71a73d62
commit
467752047e
10 changed files with 105 additions and 78 deletions
|
|
@ -794,7 +794,8 @@ tp_click_get_default_method(struct tp_dispatch *tp)
|
|||
|
||||
if (!tp->buttons.is_clickpad)
|
||||
return LIBINPUT_CONFIG_CLICK_METHOD_NONE;
|
||||
else if (evdev_device_has_model_quirk(device, QUIRK_MODEL_APPLE_TOUCHPAD))
|
||||
|
||||
if (evdev_device_has_model_quirk(device, QUIRK_MODEL_APPLE_TOUCHPAD))
|
||||
return LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
|
||||
|
||||
return LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
|
||||
|
|
@ -1286,8 +1287,7 @@ tp_post_button_events(struct tp_dispatch *tp, uint64_t time)
|
|||
if (tp->buttons.is_clickpad ||
|
||||
tp->device->model_flags & EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON)
|
||||
return tp_post_clickpadbutton_buttons(tp, time);
|
||||
else
|
||||
return tp_post_physical_buttons(tp, time);
|
||||
return tp_post_physical_buttons(tp, time);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
|||
|
|
@ -383,8 +383,7 @@ tp_gesture_handle_state_none(struct tp_dispatch *tp, uint64_t time)
|
|||
if (!tp->gesture.enabled) {
|
||||
if (ntouches == 2)
|
||||
return GESTURE_STATE_SCROLL;
|
||||
else
|
||||
return GESTURE_STATE_NONE;
|
||||
return GESTURE_STATE_NONE;
|
||||
}
|
||||
|
||||
first = touches[0];
|
||||
|
|
@ -525,9 +524,8 @@ tp_gesture_handle_state_unknown(struct tp_dispatch *tp, uint64_t time)
|
|||
if (tp->gesture.finger_count == 2) {
|
||||
tp_gesture_set_scroll_buildup(tp);
|
||||
return GESTURE_STATE_SCROLL;
|
||||
} else {
|
||||
return GESTURE_STATE_SWIPE;
|
||||
}
|
||||
return GESTURE_STATE_SWIPE;
|
||||
}
|
||||
|
||||
/* If one touch exceeds the max_move threshold while the other has not
|
||||
|
|
@ -589,7 +587,9 @@ tp_gesture_handle_state_unknown(struct tp_dispatch *tp, uint64_t time)
|
|||
if (tp->gesture.finger_count == 2) {
|
||||
tp_gesture_set_scroll_buildup(tp);
|
||||
return GESTURE_STATE_SCROLL;
|
||||
} else if (tp->gesture.enabled) {
|
||||
}
|
||||
|
||||
if (tp->gesture.enabled) {
|
||||
return GESTURE_STATE_SWIPE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -256,8 +256,9 @@ tp_fake_finger_count(struct tp_dispatch *tp)
|
|||
|
||||
if (tp->fake_touches & FAKE_FINGER_OVERFLOW)
|
||||
return FAKE_FINGER_OVERFLOW;
|
||||
else /* don't count BTN_TOUCH */
|
||||
return ffs(tp->fake_touches >> 1);
|
||||
|
||||
/* don't count BTN_TOUCH */
|
||||
return ffs(tp->fake_touches >> 1);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
|
|
@ -898,7 +899,9 @@ tp_palm_detect_dwt_triggered(struct tp_dispatch *tp,
|
|||
t->palm.state = PALM_TYPING;
|
||||
t->palm.first = t->point;
|
||||
return true;
|
||||
} else if (!tp->dwt.keyboard_active &&
|
||||
}
|
||||
|
||||
if (!tp->dwt.keyboard_active &&
|
||||
t->state == TOUCH_UPDATE &&
|
||||
t->palm.state == PALM_TYPING) {
|
||||
/* If a touch has started before the first or after the last
|
||||
|
|
@ -932,7 +935,9 @@ tp_palm_detect_trackpoint_triggered(struct tp_dispatch *tp,
|
|||
tp->palm.trackpoint_active) {
|
||||
t->palm.state = PALM_TRACKPOINT;
|
||||
return true;
|
||||
} else if (t->palm.state == PALM_TRACKPOINT &&
|
||||
}
|
||||
|
||||
if (t->palm.state == PALM_TRACKPOINT &&
|
||||
t->state == TOUCH_UPDATE &&
|
||||
!tp->palm.trackpoint_active) {
|
||||
|
||||
|
|
@ -1074,7 +1079,9 @@ tp_palm_detect_edge(struct tp_dispatch *tp,
|
|||
t->index);
|
||||
}
|
||||
return false;
|
||||
} else if (tp_palm_detect_multifinger(tp, t, time)) {
|
||||
}
|
||||
|
||||
if (tp_palm_detect_multifinger(tp, t, time)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -2327,7 +2334,8 @@ tp_want_dwt(struct evdev_device *touchpad,
|
|||
considered a happy couple */
|
||||
if (touchpad->tags & EVDEV_TAG_EXTERNAL_TOUCHPAD)
|
||||
return vendor_tp == vendor_kbd && product_tp == product_kbd;
|
||||
else if (keyboard->tags & EVDEV_TAG_INTERNAL_KEYBOARD)
|
||||
|
||||
if (keyboard->tags & EVDEV_TAG_INTERNAL_KEYBOARD)
|
||||
return true;
|
||||
|
||||
/* keyboard is not tagged as internal keyboard and it's not part of
|
||||
|
|
@ -2684,14 +2692,16 @@ evdev_tag_touchpad(struct evdev_device *device,
|
|||
if (streq(prop, "internal")) {
|
||||
evdev_tag_touchpad_internal(device);
|
||||
return;
|
||||
} else if (streq(prop, "external")) {
|
||||
}
|
||||
|
||||
if (streq(prop, "external")) {
|
||||
evdev_tag_touchpad_external(device);
|
||||
return;
|
||||
} else {
|
||||
evdev_log_info(device,
|
||||
"tagged with unknown value %s\n",
|
||||
prop);
|
||||
}
|
||||
|
||||
evdev_log_info(device,
|
||||
"tagged with unknown value %s\n",
|
||||
prop);
|
||||
}
|
||||
|
||||
/* The hwdb is the authority on integration, these heuristics are
|
||||
|
|
|
|||
12
src/evdev.c
12
src/evdev.c
|
|
@ -763,8 +763,8 @@ evdev_scroll_get_button_lock(struct libinput_device *device)
|
|||
|
||||
if (evdev->scroll.lock_state == BUTTONSCROLL_LOCK_DISABLED)
|
||||
return LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_DISABLED;
|
||||
else
|
||||
return LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_ENABLED;
|
||||
|
||||
return LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_ENABLED;
|
||||
}
|
||||
|
||||
static enum libinput_config_scroll_button_lock_state
|
||||
|
|
@ -1806,7 +1806,9 @@ evdev_configure_device(struct evdev_device *device)
|
|||
evdev_log_info(device,
|
||||
"device is an accelerometer, ignoring\n");
|
||||
return NULL;
|
||||
} else if (udev_tags & EVDEV_UDEV_TAG_ACCELEROMETER) {
|
||||
}
|
||||
|
||||
if (udev_tags & EVDEV_UDEV_TAG_ACCELEROMETER) {
|
||||
evdev_disable_accelerometer_axes(device);
|
||||
}
|
||||
|
||||
|
|
@ -1853,7 +1855,9 @@ evdev_configure_device(struct evdev_device *device)
|
|||
evdev_log_info(device, "device is a tablet pad\n");
|
||||
return dispatch;
|
||||
|
||||
} else if ((udev_tags & tablet_tags) == EVDEV_UDEV_TAG_TABLET) {
|
||||
}
|
||||
|
||||
if ((udev_tags & tablet_tags) == EVDEV_UDEV_TAG_TABLET) {
|
||||
dispatch = evdev_tablet_create(device);
|
||||
device->seat_caps |= EVDEV_DEVICE_TABLET;
|
||||
evdev_log_info(device, "device is a tablet\n");
|
||||
|
|
|
|||
|
|
@ -2020,9 +2020,9 @@ libinput_seat_unref(struct libinput_seat *seat)
|
|||
if (seat->refcount == 0) {
|
||||
libinput_seat_destroy(seat);
|
||||
return NULL;
|
||||
} else {
|
||||
return seat;
|
||||
}
|
||||
|
||||
return seat;
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT void
|
||||
|
|
@ -2086,9 +2086,9 @@ libinput_device_unref(struct libinput_device *device)
|
|||
if (device->refcount == 0) {
|
||||
libinput_device_destroy(device);
|
||||
return NULL;
|
||||
} else {
|
||||
return device;
|
||||
}
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT int
|
||||
|
|
@ -3617,9 +3617,9 @@ libinput_device_group_unref(struct libinput_device_group *group)
|
|||
if (group->refcount == 0) {
|
||||
libinput_device_group_destroy(group);
|
||||
return NULL;
|
||||
} else {
|
||||
return group;
|
||||
}
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT void
|
||||
|
|
@ -3854,8 +3854,9 @@ libinput_device_config_send_events_set_mode(struct libinput_device *device,
|
|||
|
||||
if (device->config.sendevents)
|
||||
return device->config.sendevents->set_mode(device, mode);
|
||||
else /* mode must be _ENABLED to get here */
|
||||
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
||||
|
||||
/* mode must be _ENABLED to get here */
|
||||
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT uint32_t
|
||||
|
|
@ -3863,8 +3864,8 @@ libinput_device_config_send_events_get_mode(struct libinput_device *device)
|
|||
{
|
||||
if (device->config.sendevents)
|
||||
return device->config.sendevents->get_mode(device);
|
||||
else
|
||||
return LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
|
||||
|
||||
return LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT uint32_t
|
||||
|
|
@ -4036,8 +4037,8 @@ libinput_device_config_click_get_methods(struct libinput_device *device)
|
|||
{
|
||||
if (device->config.click_method)
|
||||
return device->config.click_method->get_methods(device);
|
||||
else
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT enum libinput_config_status
|
||||
|
|
@ -4059,8 +4060,9 @@ libinput_device_config_click_set_method(struct libinput_device *device,
|
|||
|
||||
if (device->config.click_method)
|
||||
return device->config.click_method->set_method(device, method);
|
||||
else /* method must be _NONE to get here */
|
||||
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
||||
|
||||
/* method must be _NONE to get here */
|
||||
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT enum libinput_config_click_method
|
||||
|
|
@ -4068,8 +4070,8 @@ libinput_device_config_click_get_method(struct libinput_device *device)
|
|||
{
|
||||
if (device->config.click_method)
|
||||
return device->config.click_method->get_method(device);
|
||||
else
|
||||
return LIBINPUT_CONFIG_CLICK_METHOD_NONE;
|
||||
|
||||
return LIBINPUT_CONFIG_CLICK_METHOD_NONE;
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT enum libinput_config_click_method
|
||||
|
|
@ -4077,8 +4079,8 @@ libinput_device_config_click_get_default_method(struct libinput_device *device)
|
|||
{
|
||||
if (device->config.click_method)
|
||||
return device->config.click_method->get_default_method(device);
|
||||
else
|
||||
return LIBINPUT_CONFIG_CLICK_METHOD_NONE;
|
||||
|
||||
return LIBINPUT_CONFIG_CLICK_METHOD_NONE;
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT int
|
||||
|
|
@ -4087,8 +4089,8 @@ libinput_device_config_middle_emulation_is_available(
|
|||
{
|
||||
if (device->config.middle_emulation)
|
||||
return device->config.middle_emulation->available(device);
|
||||
else
|
||||
return LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
|
||||
|
||||
return LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT enum libinput_config_status
|
||||
|
|
@ -4140,8 +4142,8 @@ libinput_device_config_scroll_get_methods(struct libinput_device *device)
|
|||
{
|
||||
if (device->config.scroll_method)
|
||||
return device->config.scroll_method->get_methods(device);
|
||||
else
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT enum libinput_config_status
|
||||
|
|
@ -4164,8 +4166,9 @@ libinput_device_config_scroll_set_method(struct libinput_device *device,
|
|||
|
||||
if (device->config.scroll_method)
|
||||
return device->config.scroll_method->set_method(device, method);
|
||||
else /* method must be _NO_SCROLL to get here */
|
||||
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
||||
|
||||
/* method must be _NO_SCROLL to get here */
|
||||
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT enum libinput_config_scroll_method
|
||||
|
|
@ -4173,8 +4176,8 @@ libinput_device_config_scroll_get_method(struct libinput_device *device)
|
|||
{
|
||||
if (device->config.scroll_method)
|
||||
return device->config.scroll_method->get_method(device);
|
||||
else
|
||||
return LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
|
||||
|
||||
return LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT enum libinput_config_scroll_method
|
||||
|
|
@ -4182,8 +4185,8 @@ libinput_device_config_scroll_get_default_method(struct libinput_device *device)
|
|||
{
|
||||
if (device->config.scroll_method)
|
||||
return device->config.scroll_method->get_default_method(device);
|
||||
else
|
||||
return LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
|
||||
|
||||
return LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT enum libinput_config_status
|
||||
|
|
|
|||
|
|
@ -128,7 +128,9 @@ device_added(struct udev_device *udev_device,
|
|||
sysname,
|
||||
devnode);
|
||||
return 0;
|
||||
} else if (device == NULL) {
|
||||
}
|
||||
|
||||
if (device == NULL) {
|
||||
log_info(&input->base,
|
||||
"%-7s - failed to create input device '%s'\n",
|
||||
sysname,
|
||||
|
|
|
|||
|
|
@ -69,7 +69,9 @@ ratelimit_test(struct ratelimit *r)
|
|||
r->begin = utime;
|
||||
r->num = 1;
|
||||
return RATELIMIT_PASS;
|
||||
} else if (r->num < r->burst) {
|
||||
}
|
||||
|
||||
if (r->num < r->burst) {
|
||||
/* continue burst */
|
||||
return (++r->num == r->burst) ? RATELIMIT_THRESHOLD
|
||||
: RATELIMIT_PASS;
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ tap_default(struct libinput_device *device)
|
|||
|
||||
if (libinput_device_config_tap_get_default_enabled(device))
|
||||
return "enabled";
|
||||
else
|
||||
return "disabled";
|
||||
|
||||
return "disabled";
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
|
@ -56,8 +56,8 @@ drag_default(struct libinput_device *device)
|
|||
|
||||
if (libinput_device_config_tap_get_default_drag_enabled(device))
|
||||
return "enabled";
|
||||
else
|
||||
return "disabled";
|
||||
|
||||
return "disabled";
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
|
@ -68,8 +68,8 @@ draglock_default(struct libinput_device *device)
|
|||
|
||||
if (libinput_device_config_tap_get_default_drag_lock_enabled(device))
|
||||
return "enabled";
|
||||
else
|
||||
return "disabled";
|
||||
|
||||
return "disabled";
|
||||
}
|
||||
|
||||
static const char*
|
||||
|
|
@ -80,8 +80,8 @@ left_handed_default(struct libinput_device *device)
|
|||
|
||||
if (libinput_device_config_left_handed_get_default(device))
|
||||
return "enabled";
|
||||
else
|
||||
return "disabled";
|
||||
|
||||
return "disabled";
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
|
@ -92,8 +92,8 @@ nat_scroll_default(struct libinput_device *device)
|
|||
|
||||
if (libinput_device_config_scroll_get_default_natural_scroll_enabled(device))
|
||||
return "enabled";
|
||||
else
|
||||
return "disabled";
|
||||
|
||||
return "disabled";
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
|
@ -104,8 +104,8 @@ middle_emulation_default(struct libinput_device *device)
|
|||
|
||||
if (libinput_device_config_middle_emulation_get_default_enabled(device))
|
||||
return "enabled";
|
||||
else
|
||||
return "disabled";
|
||||
|
||||
return "disabled";
|
||||
}
|
||||
|
||||
static char *
|
||||
|
|
@ -222,8 +222,8 @@ dwt_default(struct libinput_device *device)
|
|||
|
||||
if (libinput_device_config_dwt_get_default_enabled(device))
|
||||
return "enabled";
|
||||
else
|
||||
return "disabled";
|
||||
|
||||
return "disabled";
|
||||
}
|
||||
|
||||
static char *
|
||||
|
|
@ -384,13 +384,15 @@ main(int argc, char **argv)
|
|||
if (streq(argv[1], "--help")) {
|
||||
usage();
|
||||
return 0;
|
||||
} else if (streq(argv[1], "--version")) {
|
||||
}
|
||||
|
||||
if (streq(argv[1], "--version")) {
|
||||
printf("%s\n", LIBINPUT_VERSION);
|
||||
return 0;
|
||||
} else {
|
||||
usage();
|
||||
return EXIT_INVALID_USAGE;
|
||||
}
|
||||
|
||||
usage();
|
||||
return EXIT_INVALID_USAGE;
|
||||
}
|
||||
|
||||
li = tools_open_backend(BACKEND_UDEV, seat, false, &grab);
|
||||
|
|
|
|||
|
|
@ -2200,12 +2200,17 @@ mainloop(struct record_context *ctx)
|
|||
fprintf(stderr, "Error: %m\n");
|
||||
autorestart = false;
|
||||
break;
|
||||
} else if (rc == 0) {
|
||||
}
|
||||
|
||||
if (rc == 0) {
|
||||
fprintf(stderr,
|
||||
" ... timeout%s\n",
|
||||
had_events ? "" : " (file is empty)");
|
||||
break;
|
||||
} else if (fds[0].revents != 0) { /* signal */
|
||||
|
||||
}
|
||||
|
||||
if (fds[0].revents != 0) { /* signal */
|
||||
autorestart = false;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -564,12 +564,11 @@ tools_exec_command(const char *prefix, int real_argc, char **real_argv)
|
|||
"libinput: %s is not installed\n",
|
||||
command);
|
||||
return EXIT_INVALID_USAGE;
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"Failed to execute '%s' (%s)\n",
|
||||
command,
|
||||
strerror(errno));
|
||||
}
|
||||
fprintf(stderr,
|
||||
"Failed to execute '%s' (%s)\n",
|
||||
command,
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue