[PATCH libevdev 4/8] When running against a kernel without properties, continue as usual

David Herrmann dh.herrmann at gmail.com
Mon Oct 21 01:39:55 PDT 2013


Hi Peter

On Mon, Oct 14, 2013 at 8:14 AM, Peter Hutterer
<peter.hutterer at who-t.net> wrote:
> Missing out on properties is not fatal.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  libevdev/libevdev.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c
> index fd3c010..29640f4 100644
> --- a/libevdev/libevdev.c
> +++ b/libevdev/libevdev.c
> @@ -267,8 +267,12 @@ libevdev_set_fd(struct libevdev* dev, int fd)
>         if (rc < 0)
>                 goto out;
>
> +       /* Built on a kernel with props, running against a kernel without property
> +          support. This should not be a fatal case, we'll be missing properties but other
> +          than that everything is as expected.
> +        */
>         rc = ioctl(fd, EVIOCGPROP(sizeof(dev->props)), dev->props);
> -       if (rc < 0)
> +       if (rc < 0 && errno != EINVAL)
>                 goto out;

I'm not sure whether it's really needed, but how about clearing
dev->props in case this fails? Assume the first fd on the libevdev
object supported properties, but the next fd fails with EINVAL (for
whatever reason; think async revoke) then we should clear it.

Or libevdev_set_fd() fails somewhere after the EVIOCGPROP call and the
user calls libevdev_set_fd() again with a different fd.

Yeah, seems all very unlikely, but a memset wouldn't hurt.

>
>         rc = ioctl(fd, EVIOCGBIT(EV_REL, sizeof(dev->rel_bits)), dev->rel_bits);
> --
> 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