[ofa-general] [PATCH] [DAPL v2] fix reuse of va_list in debugging mode

Patrick Marchand Latifi patrick.latifi at qlogic.com
Sat Feb 23 21:03:21 PST 2008


Make sure we reinitialize the va_list since va_list is undefined
if a function traverses the va_list with va_arg.

This patch fixes the debugging case when both stdout and syslog
output is wanted.

Signed-off-by: Patrick Marchand Latifi <patrick.latifi at qlogic.com>
---

 dapl/common/dapl_debug.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/dapl/common/dapl_debug.c b/dapl/common/dapl_debug.c
index f0959c2..9f4fa04 100644
--- a/dapl/common/dapl_debug.c
+++ b/dapl/common/dapl_debug.c
@@ -42,18 +42,19 @@ void dapl_internal_dbg_log ( DAPL_DBG_TYPE type, const char *fmt, ...)
 
     if ( type & g_dapl_dbg_type )
     {
-	va_start (args, fmt);
-
 	if ( DAPL_DBG_DEST_STDOUT & g_dapl_dbg_dest )
 	{
+	    va_start (args, fmt);
 	    dapl_os_vprintf (fmt, args);
+	    va_end (args);
 	}
 
 	if ( DAPL_DBG_DEST_SYSLOG & g_dapl_dbg_dest )
 	{
+	    va_start (args, fmt);
 	    dapl_os_syslog(fmt, args);
+	    va_end (args);
 	}
-	va_end (args);
     }
 }
 




More information about the general mailing list