[Date Prev][Date Next] [Chronological] [Thread] [Top]

Unprotected macro arguments and values



In the values of user-visible macros, the macro arguments should be
enclosed in ()'s, and so should the body if it is not atomic.

Index: ldap/include/avl.h
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/include/avl.h,v
retrieving revision 1.2
diff -u -2 -r1.2 avl.h
--- avl.h	1998/08/09 02:13:59	1.2
+++ avl.h	1998/09/18 06:02:39
@@ -30,11 +30,11 @@
 
 /* balance factor values */
-#define LH 	-1
+#define LH 	(-1)
 #define EH 	0
 #define RH 	1
 
 /* avl routines */
-#define avl_getone(x)	(x == 0 ? 0 : (x)->avl_data)
-#define avl_onenode(x)	(x == 0 || ((x)->avl_left == 0 && (x)->avl_right == 0))
+#define avl_getone(x)	((x) == 0 ? 0 : (x)->avl_data)
+#define avl_onenode(x)	((x) == 0 || ((x)->avl_left == 0 && (x)->avl_right == 0))
 extern int		avl_insert();
 extern caddr_t		avl_delete();
@@ -50,5 +50,5 @@
 #define AVL_POSTORDER	3
 /* what apply returns if it ran out of nodes */
-#define AVL_NOMORE	-6
+#define AVL_NOMORE	(-6)
 
 typedef int	(*IFP)();
Index: ldap/include/disptmpl.h
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/include/disptmpl.h,v
retrieving revision 1.1.3.1
diff -u -2 -r1.1.3.1 disptmpl.h
--- disptmpl.h	1998/08/08 22:43:13	1.1.3.1
+++ disptmpl.h	1998/09/18 06:02:40
@@ -127,11 +127,11 @@
 
 #define LDAP_SET_TMPLITEM_APPDATA( ti, datap )	\
-	(ti)->ti_appdata = (void *)(datap)
+	((ti)->ti_appdata = (void *)(datap))
 
 #define LDAP_GET_TMPLITEM_APPDATA( ti, type )	\
-	(type)((ti)->ti_appdata)
+	((type)((ti)->ti_appdata))
 
 #define LDAP_IS_TMPLITEM_OPTION_SET( ti, option )	\
-	(((ti)->ti_options & option ) != 0 )
+	(((ti)->ti_options & (option) ) != 0 )
 
 
@@ -203,11 +203,11 @@
 
 #define LDAP_SET_DISPTMPL_APPDATA( dt, datap )	\
-	(dt)->dt_appdata = (void *)(datap)
+	((dt)->dt_appdata = (void *)(datap))
 
 #define LDAP_GET_DISPTMPL_APPDATA( dt, type )	\
-	(type)((dt)->dt_appdata)
+	((type)((dt)->dt_appdata))
 
 #define LDAP_IS_DISPTMPL_OPTION_SET( dt, option )	\
-	(((dt)->dt_options & option ) != 0 )
+	  (((dt)->dt_options & (option) ) != 0 )
 
 #define LDAP_TMPL_ERR_VERSION	1
Index: ldap/include/lber.h
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/include/lber.h,v
retrieving revision 1.1.3.1
diff -u -2 -r1.1.3.1 lber.h
--- lber.h	1998/08/08 22:43:13	1.1.3.1
+++ lber.h	1998/09/18 06:02:40
@@ -169,10 +169,10 @@
  */
 #ifdef MACOS
-#define SAFEMEMCPY( d, s, n )	BlockMoveData( (Ptr)s, (Ptr)d, n )
+#define SAFEMEMCPY( d, s, n )	BlockMoveData( (Ptr)(s), (Ptr)(d), (n) )
 #else /* MACOS */
 #ifdef sunos4
-#define SAFEMEMCPY( d, s, n )	bcopy( s, d, n )
+#define SAFEMEMCPY( d, s, n )	bcopy( (s), (d), (n) )
 #else /* sunos4 */
-#define SAFEMEMCPY( d, s, n )	memmove( d, s, n )
+#define SAFEMEMCPY( d, s, n )	memmove( (d), (s), (n) )
 #endif /* sunos4 */
 #endif /* MACOS */
Index: ldap/include/ldap.h
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/include/ldap.h,v
retrieving revision 1.3
diff -u -2 -r1.3 ldap.h
--- ldap.h	1998/08/20 00:18:28	1.3
+++ ldap.h	1998/09/18 06:02:40
@@ -65,14 +65,14 @@
 #define Debug( level, fmt, arg1, arg2, arg3 )	\
 	{ \
-		if ( ldap_debug & level ) \
-			fprintf( stderr, fmt, arg1, arg2, arg3 ); \
-		if ( ldap_syslog & level ) \
-			syslog( ldap_syslog_level, fmt, arg1, arg2, arg3 ); \
+		if ( ldap_debug & (level) ) \
+			fprintf( stderr, (fmt), (arg1), (arg2), (arg3) ); \
+		if ( ldap_syslog & (level) ) \
+			syslog(ldap_syslog_level,(fmt),(arg1),(arg2),(arg3)); \
 	}
 #else /* LDAP_SYSLOG */
 #ifndef WINSOCK
 #define Debug( level, fmt, arg1, arg2, arg3 ) \
-		if ( ldap_debug & level ) \
-			fprintf( stderr, fmt, arg1, arg2, arg3 );
+		if ( ldap_debug & (level) ) \
+			fprintf( stderr, (fmt), (arg1), (arg2), (arg3) );
 #else /* !WINSOCK */
 extern void Debug( int level, char* fmt, ... );
@@ -250,5 +250,5 @@
 #define LDAP_ALIAS_DEREF_PROBLEM	0x24
 
-#define NAME_ERROR(n)	((n & 0xf0) == 0x20)
+#define NAME_ERROR(n)	(((n) & 0xf0) == 0x20)
 
 #define LDAP_INAPPROPRIATE_AUTH		0x30
@@ -491,5 +491,5 @@
  * handy macro to check whether LDAP struct is set up for CLDAP or not
  */
-#define LDAP_IS_CLDAP( ld )	( ld->ld_sb.sb_naddr > 0 )
+#define LDAP_IS_CLDAP( ld )	( (ld)->ld_sb.sb_naddr > 0 )
 
 
Index: ldap/include/ldif.h
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/include/ldif.h,v
retrieving revision 1.1.3.1
diff -u -2 -r1.1.3.1 ldif.h
--- ldif.h	1998/08/08 22:43:13	1.1.3.1
+++ ldif.h	1998/09/18 06:02:40
@@ -35,5 +35,5 @@
 #define LDIF_SIZE_NEEDED(tlen,vlen) \
     ((tlen) + 4 + LDIF_BASE64_LEN(vlen) \
-    + ((LDIF_BASE64_LEN(vlen) + tlen + 3) / LINE_WIDTH * 2 ))
+    + ((LDIF_BASE64_LEN(vlen) + (tlen) + 3) / LINE_WIDTH * 2 ))
 
 
Index: ldap/include/lthread.h
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/include/lthread.h,v
retrieving revision 1.6
diff -u -2 -r1.6 lthread.h
--- lthread.h	1998/09/16 00:42:33	1.6
+++ lthread.h	1998/09/18 06:02:40
@@ -165,5 +165,5 @@
 #define pthread_attr_destroy( a )	pthread_attr_delete( a )
 #define pthread_attr_setdetachstate( a, b ) \
-					pthread_attr_setdetach_np( a, b )
+					pthread_attr_setdetach_np( (a), (b) )
 
 #else /* end dce pthreads */
Index: ldap/include/portable.h
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/include/portable.h,v
retrieving revision 1.9
diff -u -2 -r1.9 portable.h
--- portable.h	1998/08/31 18:49:27	1.9
+++ portable.h	1998/09/18 06:02:40
@@ -135,5 +135,5 @@
  * is not defined.
  */
-#define select(a,b,c,d,e) select(a, (int *)b, (int *)c, (int *)d, e)
+#define select(a,b,c,d,e) select((a), (int *)(b), (int *)(c), (int *)(d), (e))
 #endif /* hpux && __STDC__ */
 
@@ -172,9 +172,9 @@
  */
 #if defined( SYSV ) && !defined( hpux )
-#define TOUPPER(c)	(isascii(c) && islower(c) ? _toupper(c) : c)
-#define TOLOWER(c)	(isascii(c) && isupper(c) ? _tolower(c) : c)
+#define TOUPPER(c)	(isascii(c) && islower(c) ? _toupper(c) : (c))
+#define TOLOWER(c)	(isascii(c) && isupper(c) ? _tolower(c) : (c))
 #else
-#define TOUPPER(c)	(isascii(c) && islower(c) ? toupper(c) : c)
-#define TOLOWER(c)	(isascii(c) && isupper(c) ? tolower(c) : c)
+#define TOUPPER(c)	(isascii(c) && islower(c) ? toupper(c) : (c))
+#define TOLOWER(c)	(isascii(c) && isupper(c) ? tolower(c) : (c))
 #endif
 
@@ -187,6 +187,6 @@
 #define GETATTR( fd, tiop )	ioctl((fd), TIOCGETP, (caddr_t)(tiop))
 #define SETATTR( fd, tiop )	ioctl((fd), TIOCSETP, (caddr_t)(tiop))
-#define GETFLAGS( tio )		(tio).sg_flags
-#define SETFLAGS( tio, flags )	(tio).sg_flags = (flags)
+#define GETFLAGS( tio )		((tio).sg_flags)
+#define SETFLAGS( tio, flags )	((tio).sg_flags = (flags))
 #else
 #define USE_TERMIOS
@@ -195,6 +195,6 @@
 #define GETATTR( fd, tiop )	tcgetattr((fd), (tiop))
 #define SETATTR( fd, tiop )	tcsetattr((fd), TCSANOW /* 0 */, (tiop))
-#define GETFLAGS( tio )		(tio).c_lflag
-#define SETFLAGS( tio, flags )	(tio).c_lflag = (flags)
+#define GETFLAGS( tio )		((tio).c_lflag)
+#define SETFLAGS( tio, flags )	((tio).c_lflag = (flags))
 #endif
 
Index: ldap/include/srchpref.h
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/include/srchpref.h,v
retrieving revision 1.1.3.1
diff -u -2 -r1.1.3.1 srchpref.h
--- srchpref.h	1998/08/08 22:43:13	1.1.3.1
+++ srchpref.h	1998/09/18 06:02:40
@@ -61,5 +61,5 @@
 
 #define LDAP_IS_SEARCHOBJ_OPTION_SET( so, option )	\
-	(((so)->so_options & option ) != 0 )
+	(((so)->so_options & (option) ) != 0 )
 
 #define LDAP_SEARCHPREF_VERSION_ZERO	0