mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] silence spinlock/rwlock uninitialized break_lock member warnings
@ 2005-04-09  0:01 Jesper Juhl
  2005-04-09  0:10 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Jesper Juhl @ 2005-04-09  0:01 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Zwane Mwaikambo, Ingo Molnar, Robert Love, linux-kernel


Hi Andrew,

Any chance this patch could be added to -mm (and possibly mainline)?

It removes a bunch of warnings when building with gcc -W, like these:
include/linux/wait.h:82: warning: missing initializer
include/linux/wait.h:82: warning: (near initialization for `(anonymous).break_lock')
include/asm/rwsem.h:88: warning: missing initializer
include/asm/rwsem.h:88: warning: (near initialization for `(anonymous).break_lock')
so there's less to sift through when looking for real problems with this 
patch applied. 
I've been using it for a while with no ill effects.

This patch has surfaced previously, please see the lkml thread 
"[RFC] spinlock_t & rwlock_t break_lock member initialization (patch seeking comments included)" 


Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>

---

 spinlock.h |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)


--- linux-2.6.12-rc2-mm2-orig/include/asm-i386/spinlock.h	2005-03-02 08:37:50.000000000 +0100
+++ linux-2.6.12-rc2-mm2/include/asm-i386/spinlock.h	2005-04-09 01:49:48.000000000 +0200
@@ -32,7 +32,13 @@ typedef struct {
 #define SPINLOCK_MAGIC_INIT	/* */
 #endif
 
-#define SPIN_LOCK_UNLOCKED (spinlock_t) { 1 SPINLOCK_MAGIC_INIT }
+#ifdef CONFIG_PREEMPT
+#define SPINLOCK_BREAK_INIT	, 0
+#else
+#define SPINLOCK_BREAK_INIT	/* */
+#endif
+
+#define SPIN_LOCK_UNLOCKED (spinlock_t) { 1 SPINLOCK_MAGIC_INIT SPINLOCK_BREAK_INIT }
 
 #define spin_lock_init(x)	do { *(x) = SPIN_LOCK_UNLOCKED; } while(0)
 
@@ -182,7 +188,13 @@ typedef struct {
 #define RWLOCK_MAGIC_INIT	/* */
 #endif
 
-#define RW_LOCK_UNLOCKED (rwlock_t) { RW_LOCK_BIAS RWLOCK_MAGIC_INIT }
+#ifdef CONFIG_PREEMPT
+#define RWLOCK_BREAK_INIT	, 0
+#else
+#define RWLOCK_BREAK_INIT	/* */
+#endif
+
+#define RW_LOCK_UNLOCKED (rwlock_t) { RW_LOCK_BIAS RWLOCK_MAGIC_INIT RWLOCK_BREAK_INIT }
 
 #define rwlock_init(x)	do { *(x) = RW_LOCK_UNLOCKED; } while(0)
 




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

* Re: [PATCH] silence spinlock/rwlock uninitialized break_lock member warnings
  2005-04-09  0:01 [PATCH] silence spinlock/rwlock uninitialized break_lock member warnings Jesper Juhl
@ 2005-04-09  0:10 ` Andrew Morton
  2005-04-09  0:23   ` Jesper Juhl
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2005-04-09  0:10 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: zwane, mingo, rml, linux-kernel

Jesper Juhl <juhl-lkml@dif.dk> wrote:
>
> Any chance this patch could be added to -mm (and possibly mainline)?

Spose I can stick it in -mm.

> It removes a bunch of warnings when building with gcc -W, like these:
> include/linux/wait.h:82: warning: missing initializer
> include/linux/wait.h:82: warning: (near initialization for `(anonymous).break_lock')
> include/asm/rwsem.h:88: warning: missing initializer
> include/asm/rwsem.h:88: warning: (near initialization for `(anonymous).break_lock')
> so there's less to sift through when looking for real problems with this 
> patch applied. 
> I've been using it for a while with no ill effects.

But I'd rather not add a bunch of even-more-ifdefs to support a compiler
flag which we're not going to use.  It's easy enough for the `gcc -W' user
to add the patch himself.



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

* Re: [PATCH] silence spinlock/rwlock uninitialized break_lock member warnings
  2005-04-09  0:10 ` Andrew Morton
@ 2005-04-09  0:23   ` Jesper Juhl
  0 siblings, 0 replies; 3+ messages in thread
From: Jesper Juhl @ 2005-04-09  0:23 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jesper Juhl, zwane, mingo, rml, linux-kernel

On Fri, 8 Apr 2005, Andrew Morton wrote:

> Jesper Juhl <juhl-lkml@dif.dk> wrote:
> >
> > Any chance this patch could be added to -mm (and possibly mainline)?
> 
> Spose I can stick it in -mm.
> 
> > It removes a bunch of warnings when building with gcc -W, like these:
> > include/linux/wait.h:82: warning: missing initializer
> > include/linux/wait.h:82: warning: (near initialization for `(anonymous).break_lock')
> > include/asm/rwsem.h:88: warning: missing initializer
> > include/asm/rwsem.h:88: warning: (near initialization for `(anonymous).break_lock')
> > so there's less to sift through when looking for real problems with this 
> > patch applied. 
> > I've been using it for a while with no ill effects.
> 
> But I'd rather not add a bunch of even-more-ifdefs to support a compiler
> flag which we're not going to use.  It's easy enough for the `gcc -W' user
> to add the patch himself.
> 
True, it's trivial to just add the patch when needed (aka building with 
-W), but the number of such patches add up and having them in the tree by 
default is less pain (for the -W user).  I'm not on a quest to make the 
tree -W clean, but I find -W useful to find the odd actual problem and a 
number of the warnings that -W spits out can be silenced without harm, 
those are the ones I aim to fix. But I see the point of not adding patches 
to make -W happy if it adds clutter for the non-W case, so I'll see if I 
can come up with a cleaner way to fix this case that will be more 
generally acceptable (perhaps Zwane's suggestion about using named 
initializers could result in something cleaner - I'll look at that)...


-- 
Jesper



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

end of thread, other threads:[~2005-04-09  0:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-09  0:01 [PATCH] silence spinlock/rwlock uninitialized break_lock member warnings Jesper Juhl
2005-04-09  0:10 ` Andrew Morton
2005-04-09  0:23   ` Jesper Juhl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®