summaryrefslogtreecommitdiff
path: root/tools/iio
diff options
context:
space:
mode:
authorHartmut Knaack <knaack.h@gmx.de>2015-05-31 15:40:05 +0300
committerJonathan Cameron <jic23@kernel.org>2015-05-31 21:25:12 +0300
commit963f54cef23b7e8c91bbe60b978b5f4a3e990f2c (patch)
tree34b452ec0d0695fd41b269e18c0850ca0ff7b474 /tools/iio
parent6bb7cac8551e2d60edbd25a6d046cc45932c4c3e (diff)
downloadlinux-963f54cef23b7e8c91bbe60b978b5f4a3e990f2c.tar.xz
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 <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'tools/iio')
-rw-r--r--tools/iio/iio_event_monitor.c9
1 files changed, 7 insertions, 2 deletions
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: