tools:iio: save errno first
authorHartmut Knaack <knaack.h@gmx.de>
Sun, 31 May 2015 12:39:48 +0000 (14:39 +0200)
committerJonathan Cameron <jic23@kernel.org>
Sun, 31 May 2015 16:32:44 +0000 (17:32 +0100)
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>
tools/iio/generic_buffer.c
tools/iio/iio_event_monitor.c
tools/iio/iio_utils.c

index 0410948..7635aeb 100644 (file)
@@ -296,8 +296,8 @@ int main(int argc, char **argv)
        /* Attempt to open non blocking the access dev */
        fp = open(buffer_access, O_RDONLY | O_NONBLOCK);
        if (fp == -1) { /* If it isn't there make the node */
-               printf("Failed to open %s\n", buffer_access);
                ret = -errno;
+               printf("Failed to open %s\n", buffer_access);
                goto error_free_buffer_access;
        }
 
Simple merge
Simple merge