[PATCH libinput 2/6] Change a few functions that only ever returned 0 to voids
Peter Hutterer
peter.hutterer at who-t.net
Wed Jul 20 01:43:07 UTC 2016
On Tue, Jul 19, 2016 at 12:49:21PM -0700, Yong Bakos wrote:
> Hi Peter,
> I'm curious about the explicit return at the end of tp_process_button,
> inline below...
>
>
> > On Jul 18, 2016, at 5:49 PM, Peter Hutterer <peter.hutterer at who-t.net> wrote:
> >
> > These are internal functions, if we need them to return an error code we can
> > change that at any time. Meanwhile, if we only ever return 0 anyway we might
> > as well just make them voids to save on error paths.
> >
> > Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> > ---
> > src/evdev-mt-touchpad-buttons.c | 14 +++----
> > src/evdev-mt-touchpad-edge-scroll.c | 4 +-
> > src/evdev-mt-touchpad-gestures.c | 3 +-
> > src/evdev-mt-touchpad-tap.c | 4 +-
> > src/evdev-mt-touchpad.c | 77 ++++++++++++-------------------------
> > src/evdev-mt-touchpad.h | 12 +++---
> > src/evdev-tablet.c | 5 +--
> > src/evdev.c | 34 ++++++----------
> > src/evdev.h | 4 +-
> > 9 files changed, 53 insertions(+), 104 deletions(-)
> >
> > diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c
> > index 85a355f..ba0a016 100644
> > --- a/src/evdev-mt-touchpad-buttons.c
> > +++ b/src/evdev-mt-touchpad-buttons.c
> > @@ -452,7 +452,7 @@ tp_button_handle_event(struct tp_dispatch *tp,
> > button_state_to_str(t->button.state));
> > }
> >
> > -int
> > +void
> > tp_button_handle_state(struct tp_dispatch *tp, uint64_t time)
> > {
> > struct tp_touch *t;
> > @@ -488,8 +488,6 @@ tp_button_handle_state(struct tp_dispatch *tp, uint64_t time)
> > if (tp->queued & TOUCHPAD_EVENT_BUTTON_PRESS)
> > tp_button_handle_event(tp, t, BUTTON_EVENT_PRESS, time);
> > }
> > -
> > - return 0;
> > }
> >
> > static void
> > @@ -500,7 +498,7 @@ tp_button_handle_timeout(uint64_t now, void *data)
> > tp_button_handle_event(t->tp, t, BUTTON_EVENT_TIMEOUT, now);
> > }
> >
> > -int
> > +void
> > tp_process_button(struct tp_dispatch *tp,
> > const struct input_event *e,
> > uint64_t time)
> > @@ -513,7 +511,7 @@ tp_process_button(struct tp_dispatch *tp,
> > log_bug_kernel(libinput,
> > "received %s button event on a clickpad\n",
> > libevdev_event_code_get_name(EV_KEY, e->code));
> > - return 0;
> > + return;
> > }
> >
> > if (e->value) {
> > @@ -524,7 +522,7 @@ tp_process_button(struct tp_dispatch *tp,
> > tp->queued |= TOUCHPAD_EVENT_BUTTON_RELEASE;
> > }
> >
> > - return 0;
> > + return;
> > }
>
> Why the explicit return here?
no reason, just an oversight, I've removed it locally. Thanks.
Cheers,
Peter
> >
> > void
> > @@ -831,7 +829,7 @@ tp_init_middlebutton_emulation(struct tp_dispatch *tp,
> > want_config_option);
> > }
> >
> > -int
> > +void
> > tp_init_buttons(struct tp_dispatch *tp,
> > struct evdev_device *device)
> > {
> > @@ -884,8 +882,6 @@ tp_init_buttons(struct tp_dispatch *tp,
> > tp_libinput_context(tp),
> > tp_button_handle_timeout, t);
> > }
> > -
> > - return 0;
> > }
> >
> > void
> > diff --git a/src/evdev-mt-touchpad-edge-scroll.c b/src/evdev-mt-touchpad-edge-scroll.c
> > index 610744a..22cb5ae 100644
> > --- a/src/evdev-mt-touchpad-edge-scroll.c
> > +++ b/src/evdev-mt-touchpad-edge-scroll.c
> > @@ -281,7 +281,7 @@ tp_edge_scroll_handle_timeout(uint64_t now, void *data)
> > tp_edge_scroll_handle_event(t->tp, t, SCROLL_EVENT_TIMEOUT);
> > }
> >
> > -int
> > +void
> > tp_edge_scroll_init(struct tp_dispatch *tp, struct evdev_device *device)
> > {
> > struct tp_touch *t;
> > @@ -316,8 +316,6 @@ tp_edge_scroll_init(struct tp_dispatch *tp, struct evdev_device *device)
> > tp_libinput_context(tp),
> > tp_edge_scroll_handle_timeout, t);
> > }
> > -
> > - return 0;
> > }
> >
> > void
> > diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c
> > index a910bec..acfc875 100644
> > --- a/src/evdev-mt-touchpad-gestures.c
> > +++ b/src/evdev-mt-touchpad-gestures.c
> > @@ -621,7 +621,7 @@ tp_gesture_handle_state(struct tp_dispatch *tp, uint64_t time)
> > }
> > }
> >
> > -int
> > +void
> > tp_init_gesture(struct tp_dispatch *tp)
> > {
> > /* two-finger scrolling is always enabled, this flag just
> > @@ -634,7 +634,6 @@ tp_init_gesture(struct tp_dispatch *tp)
> > libinput_timer_init(&tp->gesture.finger_count_switch_timer,
> > tp_libinput_context(tp),
> > tp_gesture_finger_count_switch_timeout, tp);
> > - return 0;
> > }
> >
> > void
> > diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c
> > index 232cd6a..c2b331c 100644
> > --- a/src/evdev-mt-touchpad-tap.c
> > +++ b/src/evdev-mt-touchpad-tap.c
> > @@ -1010,7 +1010,7 @@ tp_tap_config_get_default_draglock_enabled(struct libinput_device *device)
> > return tp_drag_lock_default(evdev);
> > }
> >
> > -int
> > +void
> > tp_init_tap(struct tp_dispatch *tp)
> > {
> > tp->tap.config.count = tp_tap_config_count;
> > @@ -1033,8 +1033,6 @@ tp_init_tap(struct tp_dispatch *tp)
> > libinput_timer_init(&tp->tap.timer,
> > tp_libinput_context(tp),
> > tp_tap_handle_timeout, tp);
> > -
> > - return 0;
> > }
> >
> > void
> > diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
> > index 87d81c5..fe0d4a4 100644
> > --- a/src/evdev-mt-touchpad.c
> > +++ b/src/evdev-mt-touchpad.c
> > @@ -1781,7 +1781,6 @@ tp_init_accel(struct tp_dispatch *tp)
> > struct evdev_device *device = tp->device;
> > int res_x, res_y;
> > struct motion_filter *filter;
> > - int rc;
> >
> > res_x = tp->device->abs.absinfo_x->resolution;
> > res_y = tp->device->abs.absinfo_y->resolution;
> > @@ -1805,9 +1804,7 @@ tp_init_accel(struct tp_dispatch *tp)
> > if (!filter)
> > return -1;
> >
> > - rc = evdev_device_init_pointer_acceleration(tp->device, filter);
> > - if (rc != 0)
> > - return rc;
> > + evdev_device_init_pointer_acceleration(tp->device, filter);
> >
> > /* we override the profile hooks for accel configuration with hooks
> > * that don't allow selection of profiles */
> > @@ -1896,11 +1893,10 @@ tp_scroll_config_scroll_method_get_default_method(struct libinput_device *device
> > return tp_scroll_get_default_method(tp);
> > }
> >
> > -static int
> > +static void
> > tp_init_scroll(struct tp_dispatch *tp, struct evdev_device *device)
> > {
> > - if (tp_edge_scroll_init(tp, device) != 0)
> > - return -1;
> > + tp_edge_scroll_init(tp, device);
> >
> > evdev_init_natural_scroll(device);
> >
> > @@ -1914,8 +1910,6 @@ tp_init_scroll(struct tp_dispatch *tp, struct evdev_device *device)
> > /* In mm for touchpads with valid resolution, see tp_init_accel() */
> > tp->device->scroll.threshold = 0.0;
> > tp->device->scroll.direction_lock_threshold = 5.0;
> > -
> > - return 0;
> > }
> >
> > static int
> > @@ -1972,12 +1966,12 @@ tp_dwt_config_get_default(struct libinput_device *device)
> > LIBINPUT_CONFIG_DWT_DISABLED;
> > }
> >
> > -static int
> > +static void
> > tp_init_dwt(struct tp_dispatch *tp,
> > struct evdev_device *device)
> > {
> > if (tp_dwt_device_is_blacklisted(device))
> > - return 0;
> > + return;
> >
> > tp->dwt.config.is_available = tp_dwt_config_is_available;
> > tp->dwt.config.set_enabled = tp_dwt_config_set;
> > @@ -1986,10 +1980,10 @@ tp_init_dwt(struct tp_dispatch *tp,
> > tp->dwt.dwt_enabled = tp_dwt_default_enabled(tp);
> > device->base.config.dwt = &tp->dwt.config;
> >
> > - return 0;
> > + return;
> > }
> >
> > -static int
> > +static void
> > tp_init_palmdetect(struct tp_dispatch *tp,
> > struct evdev_device *device)
> > {
> > @@ -2002,23 +1996,21 @@ tp_init_palmdetect(struct tp_dispatch *tp,
> >
> > /* Wacom doesn't have internal touchpads */
> > if (device->model_flags & EVDEV_MODEL_WACOM_TOUCHPAD)
> > - return 0;
> > + return;
> >
> > /* Enable palm detection on touchpads >= 70 mm. Anything smaller
> > probably won't need it, until we find out it does */
> > if (width/device->abs.absinfo_x->resolution < 70)
> > - return 0;
> > + return;
> >
> > /* palm edges are 5% of the width on each side */
> > tp->palm.right_edge = device->abs.absinfo_x->maximum - width * 0.05;
> > tp->palm.left_edge = device->abs.absinfo_x->minimum + width * 0.05;
> >
> > tp->palm.monitor_trackpoint = true;
> > -
> > - return 0;
> > }
> >
> > -static int
> > +static void
> > tp_init_sendevents(struct tp_dispatch *tp,
> > struct evdev_device *device)
> > {
> > @@ -2029,10 +2021,9 @@ tp_init_sendevents(struct tp_dispatch *tp,
> > libinput_timer_init(&tp->dwt.keyboard_timer,
> > tp_libinput_context(tp),
> > tp_keyboard_timeout, tp);
> > - return 0;
> > }
> >
> > -static int
> > +static void
> > tp_init_thumb(struct tp_dispatch *tp)
> > {
> > struct evdev_device *device = tp->device;
> > @@ -2043,14 +2034,14 @@ tp_init_thumb(struct tp_dispatch *tp)
> > double threshold;
> >
> > if (!tp->buttons.is_clickpad)
> > - return 0;
> > + return;
> >
> > /* if the touchpad is less than 50mm high, skip thumb detection.
> > * it's too small to meaningfully interact with a thumb on the
> > * touchpad */
> > evdev_device_get_size(device, &w, &h);
> > if (h < 50)
> > - return 0;
> > + return;
> >
> > tp->thumb.detect_thumbs = true;
> > tp->thumb.threshold = INT_MAX;
> > @@ -2086,8 +2077,6 @@ out:
> > "thumb: enabled thumb detection%s on '%s'\n",
> > tp->thumb.threshold != INT_MAX ? " (+pressure)" : "",
> > device->devname);
> > -
> > - return 0;
> > }
> >
> > static int
> > @@ -2115,7 +2104,7 @@ error:
> > return -1;
> > }
> >
> > -static int
> > +static void
> > tp_init_default_resolution(struct tp_dispatch *tp,
> > struct evdev_device *device)
> > {
> > @@ -2124,7 +2113,7 @@ tp_init_default_resolution(struct tp_dispatch *tp,
> > int xres, yres;
> >
> > if (!device->abs.fake_resolution)
> > - return 0 ;
> > + return;
> >
> > /* we only get here if
> > * - the touchpad provides no resolution
> > @@ -2148,8 +2137,6 @@ tp_init_default_resolution(struct tp_dispatch *tp,
> > libevdev_set_abs_resolution(device->evdev, ABS_MT_POSITION_X, xres);
> > libevdev_set_abs_resolution(device->evdev, ABS_MT_POSITION_Y, yres);
> > device->abs.fake_resolution = 0;
> > -
> > - return 0;
> > }
> >
> > static inline void
> > @@ -2197,8 +2184,7 @@ tp_init(struct tp_dispatch *tp,
> > if (tp_sanity_check(tp, device) != 0)
> > return -1;
> >
> > - if (tp_init_default_resolution(tp, device) != 0)
> > - return -1;
> > + tp_init_default_resolution(tp, device);
> >
> > if (tp_init_slots(tp, device) != 0)
> > return -1;
> > @@ -2217,29 +2203,14 @@ tp_init(struct tp_dispatch *tp,
> > if (tp_init_accel(tp) != 0)
> > return -1;
> >
> > - if (tp_init_tap(tp) != 0)
> > - return -1;
> > -
> > - if (tp_init_buttons(tp, device) != 0)
> > - return -1;
> > -
> > - if (tp_init_dwt(tp, device) != 0)
> > - return -1;
> > -
> > - if (tp_init_palmdetect(tp, device) != 0)
> > - return -1;
> > -
> > - if (tp_init_sendevents(tp, device) != 0)
> > - return -1;
> > -
> > - if (tp_init_scroll(tp, device) != 0)
> > - return -1;
> > -
> > - if (tp_init_gesture(tp) != 0)
> > - return -1;
> > -
> > - if (tp_init_thumb(tp) != 0)
> > - return -1;
> > + tp_init_tap(tp);
> > + tp_init_buttons(tp, device);
> > + tp_init_dwt(tp, device);
> > + tp_init_palmdetect(tp, device);
> > + tp_init_sendevents(tp, device);
> > + tp_init_scroll(tp, device);
> > + tp_init_gesture(tp);
> > + tp_init_thumb(tp);
> >
> > device->seat_caps |= EVDEV_DEVICE_POINTER;
> > if (tp->gesture.enabled)
> > diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
> > index fe1f1b3..24912aa 100644
> > --- a/src/evdev-mt-touchpad.h
> > +++ b/src/evdev-mt-touchpad.h
> > @@ -428,13 +428,13 @@ tp_touch_active(const struct tp_dispatch *tp, const struct tp_touch *t);
> > int
> > tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time);
> >
> > -int
> > +void
> > tp_init_tap(struct tp_dispatch *tp);
> >
> > void
> > tp_remove_tap(struct tp_dispatch *tp);
> >
> > -int
> > +void
> > tp_init_buttons(struct tp_dispatch *tp, struct evdev_device *device);
> >
> > void
> > @@ -445,7 +445,7 @@ tp_init_top_softbuttons(struct tp_dispatch *tp,
> > void
> > tp_remove_buttons(struct tp_dispatch *tp);
> >
> > -int
> > +void
> > tp_process_button(struct tp_dispatch *tp,
> > const struct input_event *e,
> > uint64_t time);
> > @@ -457,7 +457,7 @@ tp_release_all_buttons(struct tp_dispatch *tp,
> > int
> > tp_post_button_events(struct tp_dispatch *tp, uint64_t time);
> >
> > -int
> > +void
> > tp_button_handle_state(struct tp_dispatch *tp, uint64_t time);
> >
> > int
> > @@ -481,7 +481,7 @@ tp_tap_resume(struct tp_dispatch *tp, uint64_t time);
> > bool
> > tp_tap_dragging(const struct tp_dispatch *tp);
> >
> > -int
> > +void
> > tp_edge_scroll_init(struct tp_dispatch *tp, struct evdev_device *device);
> >
> > void
> > @@ -503,7 +503,7 @@ tp_edge_scroll_touch_active(const struct tp_dispatch *tp,
> > uint32_t
> > tp_touch_get_edge(const struct tp_dispatch *tp, const struct tp_touch *t);
> >
> > -int
> > +void
> > tp_init_gesture(struct tp_dispatch *tp);
> >
> > void
> > diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
> > index d751f2f..a47f9e8 100644
> > --- a/src/evdev-tablet.c
> > +++ b/src/evdev-tablet.c
> > @@ -1592,7 +1592,6 @@ tablet_init_accel(struct tablet_dispatch *tablet, struct evdev_device *device)
> > {
> > const struct input_absinfo *x, *y;
> > struct motion_filter *filter;
> > - int rc;
> >
> > x = device->abs.absinfo_x;
> > y = device->abs.absinfo_y;
> > @@ -1602,9 +1601,7 @@ tablet_init_accel(struct tablet_dispatch *tablet, struct evdev_device *device)
> > if (!filter)
> > return -1;
> >
> > - rc = evdev_device_init_pointer_acceleration(device, filter);
> > - if (rc != 0)
> > - return rc;
> > + evdev_device_init_pointer_acceleration(device, filter);
> >
> > /* we override the profile hooks for accel configuration with hooks
> > * that don't allow selection of profiles */
> > diff --git a/src/evdev.c b/src/evdev.c
> > index 3a7eda1..1af8d87 100644
> > --- a/src/evdev.c
> > +++ b/src/evdev.c
> > @@ -1145,7 +1145,7 @@ evdev_left_handed_get_default(struct libinput_device *device)
> > return 0;
> > }
> >
> > -int
> > +void
> > evdev_init_left_handed(struct evdev_device *device,
> > void (*change_to_left_handed)(struct evdev_device *))
> > {
> > @@ -1157,8 +1157,6 @@ evdev_init_left_handed(struct evdev_device *device,
> > device->left_handed.enabled = false;
> > device->left_handed.want_enabled = false;
> > device->left_handed.change_to_enabled = change_to_left_handed;
> > -
> > - return 0;
> > }
> >
> > static uint32_t
> > @@ -1254,7 +1252,7 @@ evdev_scroll_get_default_button(struct libinput_device *device)
> > return 0;
> > }
> >
> > -static int
> > +static void
> > evdev_init_button_scroll(struct evdev_device *device,
> > void (*change_scroll_method)(struct evdev_device *))
> > {
> > @@ -1274,8 +1272,6 @@ evdev_init_button_scroll(struct evdev_device *device,
> > device->scroll.button = evdev_scroll_get_default_button((struct libinput_device *)device);
> > device->scroll.want_button = device->scroll.button;
> > device->scroll.change_scroll_method = change_scroll_method;
> > -
> > - return 0;
> > }
> >
> > void
> > @@ -1407,19 +1403,13 @@ fallback_dispatch_create(struct libinput_device *device)
> >
> > dispatch->interface = &fallback_interface;
> >
> > - if (evdev_device->left_handed.want_enabled &&
> > - evdev_init_left_handed(evdev_device,
> > - evdev_change_to_left_handed) == -1) {
> > - free(dispatch);
> > - return NULL;
> > - }
> > + if (evdev_device->left_handed.want_enabled)
> > + evdev_init_left_handed(evdev_device,
> > + evdev_change_to_left_handed);
> >
> > - if (evdev_device->scroll.want_button &&
> > - evdev_init_button_scroll(evdev_device,
> > - evdev_change_scroll_method) == -1) {
> > - free(dispatch);
> > - return NULL;
> > - }
> > + if (evdev_device->scroll.want_button)
> > + evdev_init_button_scroll(evdev_device,
> > + evdev_change_scroll_method);
> >
> > if (evdev_device->scroll.natural_scrolling_enabled)
> > evdev_init_natural_scroll(evdev_device);
> > @@ -1564,7 +1554,9 @@ evdev_init_accel(struct evdev_device *device,
> > if (!filter)
> > return -1;
> >
> > - return evdev_device_init_pointer_acceleration(device, filter);
> > + evdev_device_init_pointer_acceleration(device, filter);
> > +
> > + return 0;
> > }
> >
> > static int
> > @@ -1657,7 +1649,7 @@ evdev_accel_config_get_default_profile(struct libinput_device *libinput_device)
> > return LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
> > }
> >
> > -int
> > +void
> > evdev_device_init_pointer_acceleration(struct evdev_device *device,
> > struct motion_filter *filter)
> > {
> > @@ -1677,8 +1669,6 @@ evdev_device_init_pointer_acceleration(struct evdev_device *device,
> > evdev_accel_config_set_speed(&device->base,
> > evdev_accel_config_get_default_speed(&device->base));
> > }
> > -
> > - return 0;
> > }
> >
> > static inline int
> > diff --git a/src/evdev.h b/src/evdev.h
> > index f1133ee..9ddd8b3 100644
> > --- a/src/evdev.h
> > +++ b/src/evdev.h
> > @@ -319,7 +319,7 @@ void
> > evdev_init_calibration(struct evdev_device *device,
> > struct evdev_dispatch *dispatch);
> >
> > -int
> > +void
> > evdev_device_init_pointer_acceleration(struct evdev_device *device,
> > struct motion_filter *filter);
> >
> > @@ -498,7 +498,7 @@ evdev_convert_to_mm(const struct input_absinfo *absinfo, double v)
> > return value/absinfo->resolution;
> > }
> >
> > -int
> > +void
> > evdev_init_left_handed(struct evdev_device *device,
> > void (*change_to_left_handed)(struct evdev_device *));
> >
> > --
> > 2.7.4
More information about the wayland-devel
mailing list