From 5882352a2e0bd700d4ec624420aa85ed0cc62784 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Fri, 30 Apr 1999 00:53:10 +0000 Subject: [PATCH] protect multi-statement macros... ie: do { s1; s2; } while(0) --- include/ldap_log.h | 8 +++++--- servers/slapd/slap.h | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/ldap_log.h b/include/ldap_log.h index 335adb7945..c5af7c0d52 100644 --- a/include/ldap_log.h +++ b/include/ldap_log.h @@ -58,17 +58,19 @@ extern int ldap_syslog_level; /* this doesn't below as part of ldap.h */ #ifdef LDAP_SYSLOG #define Debug( level, fmt, arg1, arg2, arg3 ) \ - { \ + do { \ if ( ldap_debug & (level) ) \ fprintf( stderr, (fmt), (arg1), (arg2), (arg3) ); \ if ( ldap_syslog & (level) ) \ syslog( ldap_syslog_level, (fmt), (arg1), (arg2), (arg3) ); \ - } + } while ( 0 ) #else /* LDAP_SYSLOG */ #ifndef HAVE_WINSOCK #define Debug( level, fmt, arg1, arg2, arg3 ) \ + do { \ if ( ldap_debug & (level) ) \ - fprintf( stderr, (fmt), (arg1), (arg2), (arg3) ); + fprintf( stderr, (fmt), (arg1), (arg2), (arg3) ); \ + } while ( 0 ) #else /* !WINSOCK */ extern void Debug( int level, char* fmt, ... ); #endif /* !WINSOCK */ diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 939a4e83b4..70abfad3ce 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -452,13 +452,13 @@ typedef struct slap_conn { #if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG) #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 ) \ - { \ + do { \ if ( ldap_debug & (level) ) \ fprintf( stderr, (fmt), (connid), (opid), (arg1), (arg2), (arg3) );\ if ( ldap_syslog & (level) ) \ syslog( ldap_syslog_level, (fmt), (connid), (opid), (arg1), \ (arg2), (arg3) ); \ - } + } while (0) #else #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 ) #endif -- 2.39.5