From 711c9015c3845eb7ff733ea34829c4ecf32d8ab5 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Fri, 12 Aug 2011 17:58:07 +0200 Subject: Handle errno properly in set_debug_file_from_fd() --- src/util/debug.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/util') diff --git a/src/util/debug.c b/src/util/debug.c index e9ed8ae1..89b6217e 100644 --- a/src/util/debug.c +++ b/src/util/debug.c @@ -43,11 +43,14 @@ FILE *debug_file = NULL; errno_t set_debug_file_from_fd(const int fd) { FILE *dummy; + errno_t ret; + errno = 0; dummy = fdopen(fd, "a"); if (dummy == NULL) { - DEBUG(1, ("fdopen failed [%d][%s].\n", errno, strerror(errno))); - return errno; + ret = errno; + DEBUG(1, ("fdopen failed [%d][%s].\n", ret, strerror(ret))); + return ret; } debug_file = dummy; -- cgit