cl_log: Only close file descriptors if that had been opened

This patch also could be merged with the 6th patch in the series
(restore old open/write/close semantics). It fixes a valgrind
warning about invalid close().


Signed-off-by: Bernd Schubert <bschub...@ddn.com>


diff --git a/lib/clplumbing/cl_log.c b/lib/clplumbing/cl_log.c
--- a/lib/clplumbing/cl_log.c
+++ b/lib/clplumbing/cl_log.c
@@ -640,8 +640,10 @@ cl_direct_log(int priority, const char* 
         * program needs a signal handler. Therefore we close fd's, if the 
         * caller did not tell us it has the signal handler */
        if (have_signal_handler == FALSE) {
-               close(debug_fd);
-               close(log_fd);
+               if (debug_fd >= 0)
+                       close(debug_fd);
+               if (log_fd >=0 )
+                       close(log_fd);
                debug_fd = -1;
                log_fd = -1;
        }

_______________________________________________
Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Project Home: http://www.clusterlabs.org
Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
Bugs: http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker

Reply via email to