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

Peter Hutterer peter.hutterer at who-t.net
Mon Oct 21 03:26:35 PDT 2013


On Mon, Oct 21, 2013 at 10:39:55AM +0200, David Herrmann wrote:
> 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.

good point. I'll do this as a separate patch because this doesn't just
affect props, it affects anything and we need to zero out everything if the
first set_fd fails.

you can't call set_fd twice and have it succeed, so we're good for any case
that succeeds the first time.

Cheers,
   Peter

> 
> >
> >         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