From: Peter Hutterer Date: Mon, 1 Jul 2013 00:08:02 +0000 (+1000) Subject: Disallow disabling of EV_SYN X-Git-Tag: libevdev-0.2~40 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0aa639b4432d5665d0f79b12aaa727140a4cd13f;p=platform%2Fupstream%2Flibevdev.git Disallow disabling of EV_SYN Signed-off-by: Peter Hutterer --- diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c index fe23ce6..14bb9e4 100644 --- a/libevdev/libevdev.c +++ b/libevdev/libevdev.c @@ -795,7 +795,7 @@ libevdev_enable_event_type(struct libevdev *dev, unsigned int type) int libevdev_disable_event_type(struct libevdev *dev, unsigned int type) { - if (type > EV_MAX) + if (type > EV_MAX || type == EV_SYN) return -1; clear_bit(dev->bits, type); diff --git a/libevdev/libevdev.h b/libevdev/libevdev.h index d8f04f4..7e4c247 100644 --- a/libevdev/libevdev.h +++ b/libevdev/libevdev.h @@ -736,6 +736,9 @@ int libevdev_enable_event_type(struct libevdev *dev, unsigned int type); * In most cases, a caller likely only wants to disable a single code, not * the whole type. Use libevdev_disable_event_code() for that. * + * Disabling EV_SYN will not work. Don't shoot yourself in the foot. + * It hurts. + * * This is a local modification only affecting only this representation of * this device. * @@ -793,6 +796,9 @@ int libevdev_enable_event_code(struct libevdev *dev, unsigned int type, unsigned * This is a local modification only affecting only this representation of * this device. * + * Disabling EV_SYN will not work. Don't shoot yourself in the foot. + * It hurts. + * * @param dev The evdev device, already initialized with libevdev_set_fd() * @param type The event type to disable (EV_ABS, EV_KEY, ...) * @param code The event code to disable (ABS_X, REL_X, etc.) diff --git a/test/test-libevdev-has-event.c b/test/test-libevdev-has-event.c index 8b20f65..54a2f46 100644 --- a/test/test-libevdev-has-event.c +++ b/test/test-libevdev-has-event.c @@ -563,6 +563,7 @@ START_TEST(test_device_disable_bit_invalid) ck_assert_int_eq(libevdev_disable_event_code(dev, EV_ABS, ABS_MAX + 1), -1); ck_assert_int_eq(libevdev_disable_event_code(dev, EV_MAX + 1, ABS_MAX + 1), -1); ck_assert_int_eq(libevdev_disable_event_type(dev, EV_MAX + 1), -1); + ck_assert_int_eq(libevdev_disable_event_type(dev, EV_SYN), -1); uinput_device_free(uidev); libevdev_free(dev);