[PATCH libevdev 3/9] Return -EBADF for functions that need the fd initialized

Peter Hutterer peter.hutterer at who-t.net
Tue Sep 3 00:07:41 PDT 2013


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 libevdev/libevdev.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c
index 1c99e1f..867e008 100644
--- a/libevdev/libevdev.c
+++ b/libevdev/libevdev.c
@@ -1130,6 +1130,9 @@ libevdev_kernel_set_abs_info(struct libevdev *dev, unsigned int code, const stru
 {
 	int rc;
 
+	if (dev->fd < 0)
+		return -EBADF;
+
 	if (code > ABS_MAX)
 		return -EINVAL;
 
@@ -1147,6 +1150,9 @@ libevdev_grab(struct libevdev *dev, enum libevdev_grab_mode grab)
 {
 	int rc = 0;
 
+	if (dev->fd < 0)
+		return -EBADF;
+
 	if (grab != LIBEVDEV_GRAB && grab != LIBEVDEV_UNGRAB)
 		return -EINVAL;
 
@@ -1250,6 +1256,9 @@ libevdev_kernel_set_led_values(struct libevdev *dev, ...)
 	int rc = 0;
 	size_t nleds = 0;
 
+	if (dev->fd < 0)
+		return -EBADF;
+
 	memset(ev, 0, sizeof(ev));
 
 	va_start(args, dev);
-- 
1.8.2.1



More information about the Input-tools mailing list