linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rwsem: fix commas in initialisation
@ 2020-07-11 14:59 Alexey Dobriyan
  2020-07-13 11:51 ` Peter Zijlstra
  2020-07-17 11:22 ` [tip: locking/core] " tip-bot2 for Alexey Dobriyan
  0 siblings, 2 replies; 4+ messages in thread
From: Alexey Dobriyan @ 2020-07-11 14:59 UTC (permalink / raw)
  To: peterz, mingo, will; +Cc: linux-kernel

Leading comma prevents arbitrary reordering of initialisation clauses.
The whole point of C99 initialisation is to allow any such reordering.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 include/linux/rwsem.h |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

--- a/include/linux/rwsem.h
+++ b/include/linux/rwsem.h
@@ -66,22 +66,22 @@ static inline int rwsem_is_locked(struct rw_semaphore *sem)
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 # define __RWSEM_DEP_MAP_INIT(lockname)			\
-	, .dep_map = {					\
+	.dep_map = {					\
 		.name = #lockname,			\
 		.wait_type_inner = LD_WAIT_SLEEP,	\
-	}
+	},
 #else
 # define __RWSEM_DEP_MAP_INIT(lockname)
 #endif
 
 #ifdef CONFIG_DEBUG_RWSEMS
-# define __DEBUG_RWSEM_INITIALIZER(lockname) , .magic = &lockname
+# define __DEBUG_RWSEM_INITIALIZER(lockname) .magic = &lockname,
 #else
 # define __DEBUG_RWSEM_INITIALIZER(lockname)
 #endif
 
 #ifdef CONFIG_RWSEM_SPIN_ON_OWNER
-#define __RWSEM_OPT_INIT(lockname) , .osq = OSQ_LOCK_UNLOCKED
+#define __RWSEM_OPT_INIT(lockname) .osq = OSQ_LOCK_UNLOCKED,
 #else
 #define __RWSEM_OPT_INIT(lockname)
 #endif
@@ -90,7 +90,7 @@ static inline int rwsem_is_locked(struct rw_semaphore *sem)
 	{ __RWSEM_INIT_COUNT(name),				\
 	  .owner = ATOMIC_LONG_INIT(0),				\
 	  .wait_list = LIST_HEAD_INIT((name).wait_list),	\
-	  .wait_lock = __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock)	\
+	  .wait_lock = __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock),\
 	  __RWSEM_OPT_INIT(name)				\
 	  __DEBUG_RWSEM_INITIALIZER(name)			\
 	  __RWSEM_DEP_MAP_INIT(name) }

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-07-17 11:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-11 14:59 [PATCH] rwsem: fix commas in initialisation Alexey Dobriyan
2020-07-13 11:51 ` Peter Zijlstra
2020-07-13 14:06   ` Alexey Dobriyan
2020-07-17 11:22 ` [tip: locking/core] " tip-bot2 for Alexey Dobriyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).