From 7d8d2e1bf816222d3170afc71eae904f25e92628 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Wed, 8 Feb 2017 11:21:41 +0100 Subject: [PATCH] core: code shrink Use the ternary operator instead of an if-else. Signed-off-by: Bartosz Golaszewski --- src/lib/core.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/lib/core.c b/src/lib/core.c index 9204210..c88697c 100644 --- a/src/lib/core.c +++ b/src/lib/core.c @@ -342,18 +342,14 @@ static void line_set_state(struct gpiod_line *line, int state) static int line_get_handle_fd(struct gpiod_line *line) { - if (line_get_state(line) != LINE_TAKEN) - return -1; - else - return line->handle->request.fd; + int state = line_get_state(line); + + return state == LINE_TAKEN ? line->handle->request.fd : -1; } static int line_get_event_fd(struct gpiod_line *line) { - if (line_get_state(line) != LINE_EVENT) - return -1; - else - return line->event.fd; + return line_get_state(line) == LINE_EVENT ? line->event.fd : -1; } static void line_set_handle(struct gpiod_line *line, -- 2.30.2