summaryrefslogtreecommitdiff
path: root/tools/iio/iio_event_monitor.c
diff options
context:
space:
mode:
authorHartmut Knaack <knaack.h@gmx.de>2015-05-31 14:39:48 +0200
committerJonathan Cameron <jic23@kernel.org>2015-05-31 17:32:44 +0100
commit2b6a6e67af6f8f644a48f75efc1f44544c0d74f6 (patch)
treeffff341e8cdb92e06abd46628219495c5c2e7066 /tools/iio/iio_event_monitor.c
parentf96d055e4b38c64123f211f0521f834d649cd01c (diff)
tools:iio: save errno first
The man-page of errno states, that errno should be saved before doing any library call, as that call may have changed the value of errno. So, when encountering any error, save errno first. This patch affects generic_buffer.c, iio_event_monitor.c and iio_utils.c. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'tools/iio/iio_event_monitor.c')
-rw-r--r--tools/iio/iio_event_monitor.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c
index 427c271ac0d6..f6fdab48d340 100644
--- a/tools/iio/iio_event_monitor.c
+++ b/tools/iio/iio_event_monitor.c
@@ -269,8 +269,8 @@ int main(int argc, char **argv)
fd = open(chrdev_name, 0);
if (fd == -1) {
- fprintf(stdout, "Failed to open %s\n", chrdev_name);
ret = -errno;
+ fprintf(stdout, "Failed to open %s\n", chrdev_name);
goto error_free_chrdev_name;
}
@@ -279,8 +279,8 @@ int main(int argc, char **argv)
close(fd);
if (ret == -1 || event_fd == -1) {
- fprintf(stdout, "Failed to retrieve event fd\n");
ret = -errno;
+ fprintf(stdout, "Failed to retrieve event fd\n");
goto error_free_chrdev_name;
}
@@ -291,8 +291,8 @@ int main(int argc, char **argv)
printf("nothing available\n");
continue;
} else {
- perror("Failed to read event from device");
ret = -errno;
+ perror("Failed to read event from device");
break;
}
}