From 6886d64578125ea1f90d424d0679a36b3db3742a Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 2 Jan 2016 10:40:42 +0100 Subject: [PATCH] make various dprintf macros safer for general usage --- src/system/debug.h | 6 +++++- src/timerd/debug.h | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/system/debug.h b/src/system/debug.h index 40cba3863..a05ff1895 100644 --- a/src/system/debug.h +++ b/src/system/debug.h @@ -39,7 +39,11 @@ enum void setDebugLevel( int level ); -#define dprintf(debuglevel, fmt, args...) {if(debug>=debuglevel) printf( "[neutrino] " fmt, ## args);} +#define dprintf(debuglevel, fmt, args...) \ + do { \ + if (debug >= debuglevel) \ + printf( "[neutrino] " fmt, ## args); \ + } while(0) #define dperror(str) {perror("[neutrino] " str);} diff --git a/src/timerd/debug.h b/src/timerd/debug.h index 812842c07..76d200a9e 100644 --- a/src/timerd/debug.h +++ b/src/timerd/debug.h @@ -28,7 +28,11 @@ extern int timerd_debug; -#define dprintf(fmt, args...) {if(timerd_debug) printf( "[timerd] " fmt, ## args);} +#define dprintf(fmt, args...) \ + do { \ + if(timerd_debug) \ + printf( "[timerd] " fmt, ## args); \ + } while(0) #define dperror(str) {perror("[timerd] " str);}