From: Kurt Zeilenga Date: Fri, 30 Apr 1999 00:53:10 +0000 (+0000) Subject: protect multi-statement macros... ie: do { s1; s2; } while(0) X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~107 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5882352a2e0bd700d4ec624420aa85ed0cc62784;p=openldap protect multi-statement macros... ie: do { s1; s2; } while(0) --- 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