[PATCH libevdev 1/3] Disallow disabling EV_SYN event codes

David Herrmann dh.herrmann at gmail.com
Mon Oct 28 14:50:57 CET 2013


Hi Peter

On Thu, Oct 24, 2013 at 7:14 AM, Peter Hutterer
<peter.hutterer at who-t.net> wrote:
> The documentation already says that, make it happen.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  libevdev/libevdev.c            | 2 +-
>  test/test-libevdev-has-event.c | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c
> index d84e67e..8315d9b 100644
> --- a/libevdev/libevdev.c
> +++ b/libevdev/libevdev.c
> @@ -1213,7 +1213,7 @@ libevdev_disable_event_code(struct libevdev *dev, unsigned int type, unsigned in
>         unsigned int max;
>         unsigned long *mask = NULL;
>
> -       if (type > EV_MAX)
> +       if (type > EV_MAX || type == EV_SYN)
>                 return -1;

Maybe we should have use -EINVAL from the beginning as -1 is -EPERM.
Some functions return negative error codes and at other places we just
use -1..

Anyway, we probably cannot fix it now as we use -1 a lot already so:
Reviewed-by: David Herrmann <dh.herrmann at gmail.com>

Thanks
David

>
>         max = type_to_mask(dev, type, &mask);
> diff --git a/test/test-libevdev-has-event.c b/test/test-libevdev-has-event.c
> index 242f991..5af3530 100644
> --- a/test/test-libevdev-has-event.c
> +++ b/test/test-libevdev-has-event.c
> @@ -847,6 +847,7 @@ START_TEST(test_device_disable_bit_invalid)
>         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);
> +       ck_assert_int_eq(libevdev_disable_event_code(dev, EV_SYN, SYN_REPORT), -1);
>
>         uinput_device_free(uidev);
>         libevdev_free(dev);
> --
> 1.8.3.1
>
> _______________________________________________
> Input-tools mailing list
> Input-tools at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/input-tools


More information about the Input-tools mailing list