Commit 6bb7cac8 authored by Hartmut Knaack's avatar Hartmut Knaack Committed by Jonathan Cameron

tools:iio:generic_buffer: 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 c8ce9903
...@@ -347,7 +347,14 @@ int main(int argc, char **argv) ...@@ -347,7 +347,14 @@ int main(int argc, char **argv)
.events = POLLIN, .events = POLLIN,
}; };
poll(&pfd, 1, -1); ret = poll(&pfd, 1, -1);
if (ret < 0) {
ret = -errno;
goto error_close_buffer_access;
} else if (ret == 0) {
continue;
}
toread = buf_len; toread = buf_len;
} else { } else {
...@@ -378,11 +385,14 @@ int main(int argc, char **argv) ...@@ -378,11 +385,14 @@ int main(int argc, char **argv)
if (!notrigger) if (!notrigger)
/* Disconnect the trigger - just write a dummy name. */ /* Disconnect the trigger - just write a dummy name. */
write_sysfs_string("trigger/current_trigger", ret = write_sysfs_string("trigger/current_trigger",
dev_dir_name, "NULL"); dev_dir_name, "NULL");
if (ret < 0)
printf("Failed to write to %s\n", dev_dir_name);
error_close_buffer_access: error_close_buffer_access:
close(fp); if (close(fp) == -1)
perror("Failed to close buffer");
error_free_buffer_access: error_free_buffer_access:
free(buffer_access); free(buffer_access);
error_free_data: error_free_data:
......
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