netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] 2.6.14-rc5-mm1 net/ipv4/route.c: spin_unlock call fails to compile
@ 2005-10-28  7:08 John Bowler
  2005-10-28  9:00 ` Ingo Molnar
  0 siblings, 1 reply; 2+ messages in thread
From: John Bowler @ 2005-10-28  7:08 UTC (permalink / raw)
  To: netdev; +Cc: mingo, linux-kernel

The spin_unlock call which gets an rt_hash_lock_addr(i)
argument fails to compile on rc5-mm1 uniprocessor with
no CONFIG_DEBUG_SPINLOCK because, in mm1, the spin_unlock
macro expands to a statement of the form:

do { (void)&ptr->raw; } while (0)

and 'ptr' is 'NULL'.  Since the expression is address-of
(therefore not evaluated as an r-value - i.e. no attempt
is made to load the non-existent raw, just take its address)
this expression is harmless.

The patch makes 'ptr' ((spinlock_t*)NULL), which the compiler
can compile (sizeof *ptr is 0 in the case - the spinlock_t
struct is empty - so the patch is particularly safe.)

The patch applies to both 2.6.14 and 2.6.14-rc5-mm1 (although
only the latter requires it.)

Signed-off-by: John Bowler <jbowler@acm.org>

--- linux-2.6.14-rc5/net/ipv4/route.c	2005-10-26 08:37:20.752285410 -0700
+++ patched/net/ipv4/route.c	2005-10-26 12:17:00.761651111 -0700
@@ -231,7 +231,7 @@ static spinlock_t	*rt_hash_locks;
 			spin_lock_init(&rt_hash_locks[i]); \
 		}
 #else
-# define rt_hash_lock_addr(slot) NULL
+# define rt_hash_lock_addr(slot) ((spinlock_t*)NULL)
 # define rt_hash_lock_init()
 #endif
 

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

* Re: [PATCH] 2.6.14-rc5-mm1 net/ipv4/route.c: spin_unlock call fails to compile
  2005-10-28  7:08 [PATCH] 2.6.14-rc5-mm1 net/ipv4/route.c: spin_unlock call fails to compile John Bowler
@ 2005-10-28  9:00 ` Ingo Molnar
  0 siblings, 0 replies; 2+ messages in thread
From: Ingo Molnar @ 2005-10-28  9:00 UTC (permalink / raw)
  To: John Bowler; +Cc: netdev, linux-kernel


* John Bowler <jbowler@acm.org> wrote:

>  #else
> -# define rt_hash_lock_addr(slot) NULL
> +# define rt_hash_lock_addr(slot) ((spinlock_t*)NULL)
>  # define rt_hash_lock_init()

looks good to me - it gives (slightly) more type safety too.

	Ingo

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

end of thread, other threads:[~2005-10-28  9:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-28  7:08 [PATCH] 2.6.14-rc5-mm1 net/ipv4/route.c: spin_unlock call fails to compile John Bowler
2005-10-28  9:00 ` Ingo Molnar

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).