Commit 963f54ce authored by Hartmut Knaack's avatar Hartmut Knaack Committed by Jonathan Cameron

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: default avatarHartmut Knaack <knaack.h@gmx.de>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 6bb7cac8
No related merge requests found
......@@ -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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment