This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH roland/comma-warnings] Avoid comma operator warnings.


I'd just put this in if we weren't in release freeze.  I think it's
harmless enough to go in immediately, but it's certainly not urgent.

include/signal.h and malloc-machine.h are for internal use only, so GCC
extensions are fine unconditionally.  The generic bits/sigset.h is only
used by non-Linux configurations where there is no history of supporting
compilers older than GCC 2.x, so __extension__ ({...}) is always fine.

The build I'm doing now so as to notice these warnings is with a compiler
based on today's GCC trunk, so this warning behavior might not manifest in
any released compiler version.


Thanks,
Roland



2014-01-31  Roland McGrath  <roland@hack.frob.com>

	* bits/sigset.h (__sigemptyset): Use a statement expression rather
	than the comma operator, to avoid "rhs of comma has no effect"
	compiler warnings.
	(__sigfillset, __sigandset, __sigorset): Likewise.
	* include/signal.h (__sigemptyset): Likewise.
	* sysdeps/generic/malloc-machine.h (mutex_lock): Likewise.

--- a/bits/sigset.h
+++ b/bits/sigset.h
@@ -44,15 +44,17 @@ typedef unsigned long int __sigset_t;
    overflow if `sigset_t' is wider than `int'.  */
 #define	__sigmask(sig)	(((__sigset_t) 1) << ((sig) - 1))
 
-#define	__sigemptyset(set)	((*(set) = (__sigset_t) 0), 0)
-#define	__sigfillset(set)	((*(set) = ~(__sigset_t) 0), 0)
+#define	__sigemptyset(set)	\
+  (__extension__ ({ *(set) = (__sigset_t) 0; 0; })
+#define	__sigfillset(set)	\
+  (__extension__ ({ *(set) = ~(__sigset_t) 0; 0; }))
 
 #ifdef _GNU_SOURCE
 # define __sigisemptyset(set)	(*(set) == (__sigset_t) 0)
 # define __sigandset(dest, left, right) \
-				((*(dest) = (*(left) & *(right))), 0)
+  (__extension__ ({ *(dest) = *(left) & *(right); 0; }))
 # define __sigorset(dest, left, right) \
-				((*(dest) = (*(left) | *(right))), 0)
+  (__extension__ ({ *(dest) = *(left) | *(right); 0; }))
 #endif
 
 /* These functions needn't check for a bogus signal number -- error
--- a/include/signal.h
+++ b/include/signal.h
@@ -55,7 +55,8 @@ extern int __xpg_sigpause (int sig);
 
 /* Simplified sigemptyset() implementation without the parameter checking.  */
 #undef __sigemptyset
-#define __sigemptyset(ss) (__builtin_memset (ss, '\0', sizeof (sigset_t)), 0)
+#define __sigemptyset(ss) \
+  ({ __builtin_memset (ss, '\0', sizeof (sigset_t)); 0; })
 
 
 /* Allocate real-time signal with highest/lowest available priority.  */
--- a/sysdeps/generic/malloc-machine.h
+++ b/sysdeps/generic/malloc-machine.h
@@ -35,7 +35,7 @@
 typedef int mutex_t;
 
 # define mutex_init(m)          (*(m) = 0)
-# define mutex_lock(m)          ((*(m) = 1), 0)
+# define mutex_lock(m)          ({ *(m) = 1; 0; })
 # define mutex_trylock(m)       (*(m) ? 1 : ((*(m) = 1), 0))
 # define mutex_unlock(m)        (*(m) = 0)
 # define MUTEX_INITIALIZER      (0)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]