>From 4de19bd974d33a788b6e15f0ab83e77cc9e3f0b3 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Fri, 12 Aug 2011 17:58:07 +0200 Subject: [PATCH] Handle errno properly in set_debug_file_from_fd() --- src/util/debug.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/util/debug.c b/src/util/debug.c index e9ed8ae..89b6217 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; -- 1.7.6