Disallow disabling of EV_SYN
authorPeter Hutterer <peter.hutterer@who-t.net>
Mon, 1 Jul 2013 00:08:02 +0000 (10:08 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Mon, 1 Jul 2013 00:10:25 +0000 (10:10 +1000)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
libevdev/libevdev.c
libevdev/libevdev.h
test/test-libevdev-has-event.c

index fe23ce6c5f9854375623ffc1498fdba08ac91ee5..14bb9e4b70379e54d5ff0180d7f80b9ceff2d2db 100644 (file)
@@ -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);
index d8f04f4e5b353137e7cd47cac4019b98ff037607..7e4c2476d4a11262542a774a20732ab436f57df9 100644 (file)
@@ -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.)
index 8b20f653b2ac931e0a55bdddae07673d5fdc02ff..54a2f46d46a1430fd945c177a5782a54931da3d0 100644 (file)
@@ -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);