[PATCH 19/32] tools:iio:iio_event_monitor: add error handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add error handling to calls which can indicate a major problem by
returning an error code.

Signed-off-by: Hartmut Knaack <knaack.h@xxxxxx>
---
 tools/iio/iio_event_monitor.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c
index 1374374..1316527 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:
-- 
2.3.6

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux