[SSSD] [PATCH] Handle errno properly in set_debug_file_from_fd()
Jakub Hrozek
jhrozek at redhat.com
Fri Aug 12 16:31:47 UTC 2011
set_debug_file_from_fd would return NULL if fdopen failed as the DEBUG()
macro would overwrite errno.
-------------- next part --------------
>From 4de19bd974d33a788b6e15f0ab83e77cc9e3f0b3 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
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
More information about the sssd-devel
mailing list