core: drop unnecessary checks
authorBartosz Golaszewski <bartekgola@gmail.com>
Mon, 2 Oct 2017 14:34:05 +0000 (16:34 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Mon, 2 Oct 2017 14:36:07 +0000 (16:36 +0200)
The getter functions retrieving the file descriptors (both for events
and line values) check the line state internally but we don't check
their return values and just pass them on to ioctl()s. Drop the checks
altogether.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
src/lib/core.c

index 11d03f2fd7535296d722ae0ada71ee39fbb9204d..6ca99090eaa560380762d6353d8b21c6e200d771 100644 (file)
@@ -269,15 +269,12 @@ static void line_set_state(struct gpiod_line *line, int state)
 
 static int line_get_handle_fd(struct gpiod_line *line)
 {
-       int state = line_get_state(line);
-
-       return state == LINE_REQUESTED_VALUES ? line->handle->request.fd : -1;
+       return line->handle->request.fd;
 }
 
 static int line_get_event_fd(struct gpiod_line *line)
 {
-       return line_get_state(line) == LINE_REQUESTED_EVENTS
-                                               ? line->event.fd : -1;
+       return line->event.fd;
 }
 
 static void line_set_handle(struct gpiod_line *line,