From 786bbe4fc13c3ff19c91c3b7d9bbd1c5784251e4 Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Fri, 30 Apr 1999 00:35:27 +0000 Subject: [PATCH] enclose macro arguments in () --- clients/tools/ldapdelete.c | 2 +- clients/tools/ldapmodify.c | 2 +- clients/tools/ldapmodrdn.c | 2 +- clients/ud/print.c | 2 +- include/ldap.h | 2 +- libraries/libavl/avl.c | 2 +- libraries/libldap/tmplout.c | 14 +++++++------- libraries/libldap/tmpltest.c | 2 +- servers/ldapd/syntax.c | 4 ++-- servers/slapd/back-bdb2/cache.c | 14 +++++++------- servers/slapd/back-bdb2/search.c | 2 +- servers/slapd/back-ldbm/cache.c | 14 +++++++------- servers/slapd/back-ldbm/search.c | 2 +- servers/slapd/phonetic.c | 2 +- servers/slapd/slap.h | 10 +++++----- servers/slapd/tools/chlog2replog.c | 4 ++-- servers/slapd/tools/ldapsyntax.c | 4 ++-- tests/progs/slapd-addel.c | 2 +- 18 files changed, 43 insertions(+), 43 deletions(-) diff --git a/clients/tools/ldapdelete.c b/clients/tools/ldapdelete.c index 01c47fe645..35b3af8fba 100644 --- a/clients/tools/ldapdelete.c +++ b/clients/tools/ldapdelete.c @@ -21,7 +21,7 @@ static int ldapport = 0; static int not, verbose, contoper; static LDAP *ld; -#define safe_realloc( ptr, size ) ( ptr == NULL ? malloc( size ) : \ +#define safe_realloc( ptr, size ) ( (ptr) == NULL ? malloc( size ) : \ realloc( ptr, size )) static int dodelete LDAP_P(( diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c index 7f955623c9..44c04d0058 100644 --- a/clients/tools/ldapmodify.c +++ b/clients/tools/ldapmodify.c @@ -31,7 +31,7 @@ static int ldapport = 0; static int new, replace, not, verbose, contoper, force, valsfromfiles; static LDAP *ld; -#define safe_realloc( ptr, size ) ( ptr == NULL ? malloc( size ) : \ +#define safe_realloc( ptr, size ) ( (ptr) == NULL ? malloc( size ) : \ realloc( ptr, size )) #define LDAPMOD_MAXLINE 4096 diff --git a/clients/tools/ldapmodrdn.c b/clients/tools/ldapmodrdn.c index d6b3e99c01..9e0b920726 100644 --- a/clients/tools/ldapmodrdn.c +++ b/clients/tools/ldapmodrdn.c @@ -33,7 +33,7 @@ static int ldapport = 0; static int not, verbose, contoper; static LDAP *ld; -#define safe_realloc( ptr, size ) ( ptr == NULL ? malloc( size ) : \ +#define safe_realloc( ptr, size ) ( (ptr) == NULL ? malloc( size ) : \ realloc( ptr, size )) static int domodrdn LDAP_P(( diff --git a/clients/ud/print.c b/clients/ud/print.c index 984ee0b47d..062c403aad 100644 --- a/clients/ud/print.c +++ b/clients/ud/print.c @@ -536,7 +536,7 @@ print_one_URL( char *s, int label_lead, char *tag, int url_lead ) } -#define GET2BYTENUM( p ) (( *p - '0' ) * 10 + ( *(p+1) - '0' )) +#define GET2BYTENUM( p ) (( *(p) - '0' ) * 10 + ( *((p)+1) - '0' )) static char * time2text( char *ldtimestr, int dateonly ) diff --git a/include/ldap.h b/include/ldap.h index cbd7575574..4102153162 100644 --- a/include/ldap.h +++ b/include/ldap.h @@ -345,7 +345,7 @@ typedef struct ldapmod { #define LDAP_IS_LEAF 0x23 /* not LDAPv3 */ #define LDAP_ALIAS_DEREF_PROBLEM 0x24 -#define LDAP_NAME_ERROR(n) ((n & 0xf0) == 0x20) +#define LDAP_NAME_ERROR(n) (((n) & 0xf0) == 0x20) #define NAME_ERROR(n) LDAP_NAME_ERROR(n) /* depreciated */ #define LDAP_INAPPROPRIATE_AUTH 0x30 diff --git a/libraries/libavl/avl.c b/libraries/libavl/avl.c index c48e2e63c4..c1b1aad6cb 100644 --- a/libraries/libavl/avl.c +++ b/libraries/libavl/avl.c @@ -40,7 +40,7 @@ static char avl_version[] = "AVL library version 1.0\n"; }\ tmp = (*(x))->avl_right;\ (*(x))->avl_right = tmp->avl_left;\ - tmp->avl_left = *x;\ + tmp->avl_left = *(x);\ *(x) = tmp;\ } diff --git a/libraries/libldap/tmplout.c b/libraries/libldap/tmplout.c index 7fad7c9e99..c04550bb66 100644 --- a/libraries/libldap/tmplout.c +++ b/libraries/libldap/tmplout.c @@ -64,8 +64,8 @@ static int searchaction LDAP_P(( #define OCATTRNAME "objectClass" -#define NONFATAL_LDAP_ERR( err ) ( err == LDAP_SUCCESS || \ - err == LDAP_TIMELIMIT_EXCEEDED || err == LDAP_SIZELIMIT_EXCEEDED ) +#define NONFATAL_LDAP_ERR( err ) ( (err) == LDAP_SUCCESS || \ + (err) == LDAP_TIMELIMIT_EXCEEDED || (err) == LDAP_SIZELIMIT_EXCEEDED ) #define DEF_LDAP_URL_PREFIX "ldap:///" @@ -848,10 +848,10 @@ output_dn( char *buf, char *dn, int width, int rdncount, -#define HREF_CHAR_ACCEPTABLE( c ) (( c >= '-' && c <= '9' ) || \ - ( c >= '@' && c <= 'Z' ) || \ - ( c == '_' ) || \ - ( c >= 'a' && c <= 'z' )) +#define HREF_CHAR_ACCEPTABLE( c ) (( (c) >= '-' && (c) <= '9' ) || \ + ( (c) >= '@' && (c) <= 'Z' ) || \ + ( (c) == '_' ) || \ + ( (c) >= 'a' && (c) <= 'z' )) static void strcat_escaped( char *s1, char *s2 ) @@ -874,7 +874,7 @@ strcat_escaped( char *s1, char *s2 ) } -#define GET2BYTENUM( p ) (( *p - '0' ) * 10 + ( *(p+1) - '0' )) +#define GET2BYTENUM( p ) (( *(p) - '0' ) * 10 + ( *((p)+1) - '0' )) static char * time2text( char *ldtimestr, int dateonly ) diff --git a/libraries/libldap/tmpltest.c b/libraries/libldap/tmpltest.c index 697d4bc185..265e57e8d7 100644 --- a/libraries/libldap/tmpltest.c +++ b/libraries/libldap/tmpltest.c @@ -22,7 +22,7 @@ static void dump_tmpl ( struct ldap_disptmpl *tmpl ); static void dump_srchpref( struct ldap_searchobj *sp ); -#define NULLSTRINGIFNULL( s ) ( s == NULL ? "(null)" : s ) +#define NULLSTRINGIFNULL( s ) ( (s) == NULL ? "(null)" : (s) ) int main( int argc, char **argv ) diff --git a/servers/ldapd/syntax.c b/servers/ldapd/syntax.c index 7035991b4e..9d6032a84f 100644 --- a/servers/ldapd/syntax.c +++ b/servers/ldapd/syntax.c @@ -169,8 +169,8 @@ attr_key_rfc1779( strcpy ( key, x ); } -#define SEPARATOR(c) (c == ',' || c == ';') -#define SPACE(c) (c == ' ' || c == '\n') +#define SEPARATOR(c) ((c) == ',' || (c) == ';') +#define SPACE(c) ((c) == ' ' || (c) == '\n') int dn_print_real( diff --git a/servers/slapd/back-bdb2/cache.c b/servers/slapd/back-bdb2/cache.c index f1ce3cccc3..9a659bcfad 100644 --- a/servers/slapd/back-bdb2/cache.c +++ b/servers/slapd/back-bdb2/cache.c @@ -106,24 +106,24 @@ bdb2i_cache_return_entry_rw( struct cache *cache, Entry *e, int rw ) if ( LEI(e)->lei_lruprev != NULL ) { \ LEI(LEI(e)->lei_lruprev)->lei_lrunext = LEI(e)->lei_lrunext; \ } else { \ - cache->c_lruhead = LEI(e)->lei_lrunext; \ + (cache)->c_lruhead = LEI(e)->lei_lrunext; \ } \ if ( LEI(e)->lei_lrunext != NULL ) { \ LEI(LEI(e)->lei_lrunext)->lei_lruprev = LEI(e)->lei_lruprev; \ } else { \ - cache->c_lrutail = LEI(e)->lei_lruprev; \ + (cache)->c_lrutail = LEI(e)->lei_lruprev; \ } \ } #define LRU_ADD( cache, e ) { \ - LEI(e)->lei_lrunext = cache->c_lruhead; \ + LEI(e)->lei_lrunext = (cache)->c_lruhead; \ if ( LEI(e)->lei_lrunext != NULL ) { \ - LEI(LEI(e)->lei_lrunext)->lei_lruprev = e; \ + LEI(LEI(e)->lei_lrunext)->lei_lruprev = (e); \ } \ - cache->c_lruhead = e; \ + (cache)->c_lruhead = (e); \ LEI(e)->lei_lruprev = NULL; \ - if ( cache->c_lrutail == NULL ) { \ - cache->c_lrutail = e; \ + if ( (cache)->c_lrutail == NULL ) { \ + (cache)->c_lrutail = (e); \ } \ } diff --git a/servers/slapd/back-bdb2/search.c b/servers/slapd/back-bdb2/search.c index 5080a5faad..3090e89cca 100644 --- a/servers/slapd/back-bdb2/search.c +++ b/servers/slapd/back-bdb2/search.c @@ -19,7 +19,7 @@ static ID_BLOCK *subtree_candidates(BackendDB *be, Connection *conn, Operation * #define GRABSIZE BUFSIZ #define MAKE_SPACE( n ) { \ - if ( rcur + n > rbuf + rmaxsize ) { \ + if ( rcur + (n) > rbuf + rmaxsize ) { \ int offset = rcur - rbuf; \ rbuf = ch_realloc( rbuf, rmaxsize + GRABSIZE ); \ rmaxsize += GRABSIZE; \ diff --git a/servers/slapd/back-ldbm/cache.c b/servers/slapd/back-ldbm/cache.c index d44b14f28c..1e6d1bbd3e 100644 --- a/servers/slapd/back-ldbm/cache.c +++ b/servers/slapd/back-ldbm/cache.c @@ -180,24 +180,24 @@ cache_return_entry_rw( struct cache *cache, Entry *e, int rw ) if ( LEI(e)->lei_lruprev != NULL ) { \ LEI(LEI(e)->lei_lruprev)->lei_lrunext = LEI(e)->lei_lrunext; \ } else { \ - cache->c_lruhead = LEI(e)->lei_lrunext; \ + (cache)->c_lruhead = LEI(e)->lei_lrunext; \ } \ if ( LEI(e)->lei_lrunext != NULL ) { \ LEI(LEI(e)->lei_lrunext)->lei_lruprev = LEI(e)->lei_lruprev; \ } else { \ - cache->c_lrutail = LEI(e)->lei_lruprev; \ + (cache)->c_lrutail = LEI(e)->lei_lruprev; \ } \ } while(0) #define LRU_ADD( cache, e ) do { \ - LEI(e)->lei_lrunext = cache->c_lruhead; \ + LEI(e)->lei_lrunext = (cache)->c_lruhead; \ if ( LEI(e)->lei_lrunext != NULL ) { \ - LEI(LEI(e)->lei_lrunext)->lei_lruprev = e; \ + LEI(LEI(e)->lei_lrunext)->lei_lruprev = (e); \ } \ - cache->c_lruhead = e; \ + (cache)->c_lruhead = (e); \ LEI(e)->lei_lruprev = NULL; \ - if ( cache->c_lrutail == NULL ) { \ - cache->c_lrutail = e; \ + if ( (cache)->c_lrutail == NULL ) { \ + (cache)->c_lrutail = (e); \ } \ } while(0) diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index 04e0593193..80b184893c 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -18,7 +18,7 @@ static ID_BLOCK *subtree_candidates(Backend *be, Connection *conn, Operation *op #define GRABSIZE BUFSIZ #define MAKE_SPACE( n ) { \ - if ( rcur + n > rbuf + rmaxsize ) { \ + if ( rcur + (n) > rbuf + rmaxsize ) { \ int offset = rcur - rbuf; \ rbuf = ch_realloc( rbuf, rmaxsize + GRABSIZE ); \ rmaxsize += GRABSIZE; \ diff --git a/servers/slapd/phonetic.c b/servers/slapd/phonetic.c index 65b2a74804..f5871ee8b8 100644 --- a/servers/slapd/phonetic.c +++ b/servers/slapd/phonetic.c @@ -17,7 +17,7 @@ #define iswordbreak(x) (!isascii(x) || isspace((unsigned char) (x)) || \ ispunct((unsigned char) (x)) || \ - isdigit((unsigned char) (x)) || x == '\0') + isdigit((unsigned char) (x)) || (x) == '\0') char * first_word( char *s ) diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 7bff6d8155..939a4e83b4 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -453,11 +453,11 @@ typedef struct slap_conn { #if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG) #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 ) \ { \ - 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 ); \ + 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) ); \ } #else #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 ) diff --git a/servers/slapd/tools/chlog2replog.c b/servers/slapd/tools/chlog2replog.c index 4349779914..92dd2a302f 100644 --- a/servers/slapd/tools/chlog2replog.c +++ b/servers/slapd/tools/chlog2replog.c @@ -122,8 +122,8 @@ dn2ldap( char *edbdn ) } -#define SEPARATOR(c) (c == ',' || c == ';') -#define SPACE(c) (c == ' ' || c == '\n') +#define SEPARATOR(c) ((c) == ',' || (c) == ';') +#define SPACE(c) ((c) == ' ' || (c) == '\n') static int dn2ldif( PS ps, DN dn ) diff --git a/servers/slapd/tools/ldapsyntax.c b/servers/slapd/tools/ldapsyntax.c index 9a597ec219..4ce580697d 100644 --- a/servers/slapd/tools/ldapsyntax.c +++ b/servers/slapd/tools/ldapsyntax.c @@ -45,8 +45,8 @@ static void de_crypt( char *s ); extern char *progname; -#define SEPARATOR(c) (c == ',' || c == ';') -#define SPACE(c) (c == ' ' || c == '\n') +#define SEPARATOR(c) ((c) == ',' || (c) == ';') +#define SPACE(c) ((c) == ' ' || (c) == '\n') int diff --git a/tests/progs/slapd-addel.c b/tests/progs/slapd-addel.c index 1ed0d13400..081cd9e2a5 100644 --- a/tests/progs/slapd-addel.c +++ b/tests/progs/slapd-addel.c @@ -105,7 +105,7 @@ main( int argc, char **argv ) } -#define safe_realloc( ptr, size ) ( ptr == NULL ? malloc( size ) : \ +#define safe_realloc( ptr, size ) ( (ptr) == NULL ? malloc( size ) : \ realloc( ptr, size )) -- 2.39.5