From: Hartmut Knaack Date: Sun, 31 May 2015 12:40:05 +0000 (+0200) Subject: tools:iio:iio_event_monitor: add error handling X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=963f54cef23b7e8c91bbe60b978b5f4a3e990f2c;p=openwrt%2Fstaging%2Fblogic.git tools:iio:iio_event_monitor: add error handling Add error handling to calls which can indicate a major problem by returning an error code. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c index 1374374208ee..1316527f3c3c 100644 --- a/tools/iio/iio_event_monitor.c +++ b/tools/iio/iio_event_monitor.c @@ -286,7 +286,10 @@ int main(int argc, char **argv) goto error_free_chrdev_name; } - close(fd); + if (close(fd) == -1) { + ret = -errno; + goto error_free_chrdev_name; + } while (true) { ret = read(event_fd, &event, sizeof(event)); @@ -304,7 +307,9 @@ int main(int argc, char **argv) print_event(&event); } - close(event_fd); + if (close(event_fd) == -1) + perror("Failed to close event file"); + error_free_chrdev_name: free(chrdev_name); error_ret: