Return EBADF when trying to read from an uninitalized device

All other functions that check the fd for validity return EBADF, which also makes it
easier to debug if the actual device goes away.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
Peter Hutterer 2013-08-31 12:33:33 +10:00
parent 9675287062
commit 2c101977b7

View file

@ -663,7 +663,7 @@ libevdev_next_event(struct libevdev *dev, unsigned int flags, struct input_event
int rc = 0;
if (dev->fd < 0)
return -ENODEV;
return -EBADF;
if (!(flags & (LIBEVDEV_READ_NORMAL|LIBEVDEV_READ_SYNC|LIBEVDEV_FORCE_SYNC)))
return -EINVAL;