From 7385f34a3c8c68cf0f87d64e55e0ca44f46fdeaa Mon Sep 17 00:00:00 2001 From: Dmitri Pal Date: Wed, 12 Aug 2009 13:41:56 -0400 Subject: TRACE: Making sure trace is safe to output NULL strings Patch adds checks for NULL to the trace macros. It also eliminates the unused trace.h in the collection directory. --- common/trace/trace.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'common/trace/trace.h') diff --git a/common/trace/trace.h b/common/trace/trace.h index 9211e20d6..b2604fd58 100644 --- a/common/trace/trace.h +++ b/common/trace/trace.h @@ -45,7 +45,8 @@ extern unsigned trace_level; do { \ if (level & trace_level) { \ printf("[DEBUG] %23s (%4d) %s %s\n", \ - __FILE__, __LINE__, msg, str); \ + __FILE__, __LINE__, (msg != NULL) ? msg : "MISSING MESSAGE", \ + (str != NULL) ? str : "(null)"); \ } \ } while(0) @@ -54,7 +55,8 @@ extern unsigned trace_level; do { \ if (level & trace_level) { \ printf("[DEBUG] %23s (%4d) %s %lu\n", \ - __FILE__, __LINE__, msg, (unsigned long int)(num)); \ + __FILE__, __LINE__, (msg != NULL) ? msg : "MISSING MESSAGE", \ + (unsigned long int)(num)); \ } \ } while(0) @@ -63,7 +65,8 @@ extern unsigned trace_level; do { \ if (level & trace_level) { \ printf("[DEBUG] %23s (%4d) %s %e\n", \ - __FILE__, __LINE__, msg, (double)(num)); \ + __FILE__, __LINE__, (msg != NULL) ? msg : "MISSING MESSAGE", \ + (double)(num)); \ } \ } while(0) -- cgit