Add a few 0 enum values to shut up clang-tidy

These are all internal API so having a NONE value means we can shut up
warnings about 0 not being an enum value without having those exposed in
our public API.

And they slightly improve readability in the callers anyway.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1175>
This commit is contained in:
Peter Hutterer 2025-04-03 09:28:21 +10:00 committed by Marge Bot
parent a55dd604e1
commit f123da174e
4 changed files with 16 additions and 12 deletions

View file

@ -53,6 +53,7 @@
#define DEFAULT_BUTTON_SCROLL_TIMEOUT ms2us(200)
enum evdev_device_udev_tags {
EVDEV_UDEV_TAG_NONE = 0,
EVDEV_UDEV_TAG_INPUT = bit(0),
EVDEV_UDEV_TAG_KEYBOARD = bit(1),
EVDEV_UDEV_TAG_MOUSE = bit(2),
@ -1690,7 +1691,7 @@ static enum evdev_device_udev_tags
evdev_device_get_udev_tags(struct evdev_device *device,
struct udev_device *udev_device)
{
enum evdev_device_udev_tags tags = 0;
enum evdev_device_udev_tags tags = EVDEV_UDEV_TAG_NONE;
int i;
for (i = 0; i < 2 && udev_device; i++) {
@ -2432,7 +2433,7 @@ evdev_device_create(struct libinput_seat *seat,
libevdev_log_func,
LIBEVDEV_LOG_ERROR,
libinput);
device->seat_caps = 0;
device->seat_caps = EVDEV_DEVICE_NO_CAPABILITIES;
device->is_mt = 0;
device->mtdev = NULL;
device->udev_device = udev_device_ref(udev_device);
@ -2464,7 +2465,7 @@ evdev_device_create(struct libinput_seat *seat,
evdev_pre_configure_model_quirks(device);
device->dispatch = evdev_configure_device(device);
if (device->dispatch == NULL || device->seat_caps == 0)
if (device->dispatch == NULL || device->seat_caps == EVDEV_DEVICE_NO_CAPABILITIES)
goto err;
device->source =
@ -2485,7 +2486,7 @@ err:
if (fd >= 0) {
close_restricted(libinput, fd);
if (device) {
unhandled_device = device->seat_caps == 0;
unhandled_device = device->seat_caps == EVDEV_DEVICE_NO_CAPABILITIES;
evdev_device_destroy(device);
}
}

View file

@ -43,7 +43,7 @@
#define EVDEV_FAKE_RESOLUTION 1
enum evdev_event_type {
EVDEV_NONE,
EVDEV_NONE = 0,
EVDEV_ABSOLUTE_TOUCH_DOWN = bit(0),
EVDEV_ABSOLUTE_MOTION = bit(1),
EVDEV_ABSOLUTE_TOUCH_UP = bit(2),
@ -55,6 +55,7 @@ enum evdev_event_type {
};
enum evdev_device_seat_capability {
EVDEV_DEVICE_NO_CAPABILITIES = 0,
EVDEV_DEVICE_POINTER = bit(0),
EVDEV_DEVICE_KEYBOARD = bit(1),
EVDEV_DEVICE_TOUCH = bit(2),
@ -65,6 +66,7 @@ enum evdev_device_seat_capability {
};
enum evdev_device_tags {
EVDEV_TAG_NONE = 0,
EVDEV_TAG_EXTERNAL_MOUSE = bit(0),
EVDEV_TAG_INTERNAL_TOUCHPAD = bit(1),
EVDEV_TAG_EXTERNAL_TOUCHPAD = bit(2),

View file

@ -63,6 +63,7 @@ struct quirk_tuples {
* Quirks known to libinput
*/
enum quirk {
QUIRK_NONE = 0,
QUIRK_MODEL_ALPS_SERIAL_TOUCHPAD = 100,
QUIRK_MODEL_APPLE_TOUCHPAD,
QUIRK_MODEL_APPLE_TOUCHPAD_ONEBUTTON,

View file

@ -1568,13 +1568,13 @@ START_TEST(quirks_call_NULL)
{
litest_assert(!quirks_fetch_for_device(NULL, NULL));
litest_assert(!quirks_get_uint32(NULL, 0, NULL));
litest_assert(!quirks_get_int32(NULL, 0, NULL));
litest_assert(!quirks_get_range(NULL, 0, NULL));
litest_assert(!quirks_get_dimensions(NULL, 0, NULL));
litest_assert(!quirks_get_double(NULL, 0, NULL));
litest_assert(!quirks_get_string(NULL, 0, NULL));
litest_assert(!quirks_get_bool(NULL, 0, NULL));
litest_assert(!quirks_get_uint32(NULL, QUIRK_NONE, NULL));
litest_assert(!quirks_get_int32(NULL, QUIRK_NONE, NULL));
litest_assert(!quirks_get_range(NULL, QUIRK_NONE, NULL));
litest_assert(!quirks_get_dimensions(NULL, QUIRK_NONE, NULL));
litest_assert(!quirks_get_double(NULL, QUIRK_NONE, NULL));
litest_assert(!quirks_get_string(NULL, QUIRK_NONE, NULL));
litest_assert(!quirks_get_bool(NULL, QUIRK_NONE, NULL));
}
END_TEST