From: Hartmut Knaack Date: Sun, 31 May 2015 12:39:48 +0000 (+0200) Subject: tools:iio: save errno first X-Git-Tag: omap-for-v4.2/fixes-rc1^2~92^2~256^2~45 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b6a6e67af6f8f644a48f75efc1f44544c0d74f6;p=pandora-kernel.git 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 Signed-off-by: Jonathan Cameron --- diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c index 0410948e23c2..7635aeb93dc8 100644 --- a/tools/iio/generic_buffer.c +++ b/tools/iio/generic_buffer.c @@ -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; } Reading git-diff-tree failed