mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] kernel.h: Verify that arguments to swap() are the same type
@ 2009-07-16  1:34 Joe Perches
  2009-07-16  3:19 ` Amerigo Wang
  2009-07-23 21:47 ` Andrew Morton
  0 siblings, 2 replies; 5+ messages in thread
From: Joe Perches @ 2009-07-16  1:34 UTC (permalink / raw)
  To: LKML

Signed-off-by: Joe Perches <joe@perches.com>

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index d6320a3..72878a5 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -637,8 +637,13 @@ static inline void ftrace_dump(void) { }
 /*
  * swap - swap value of @a and @b
  */
-#define swap(a, b) \
-	do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
+#define swap(a, b)				\
+do {						\
+	typeof(a) __tmp = (a);			\
+	BUILD_BUG_ON(!__same_type(__tmp, (b)));	\
+	(a) = (b);				\
+	(b) = __tmp;				\
+} while (0)
 
 /**
  * container_of - cast a member of a structure out to the containing structure



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

end of thread, other threads:[~2009-07-23 22:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-16  1:34 [PATCH] kernel.h: Verify that arguments to swap() are the same type Joe Perches
2009-07-16  3:19 ` Amerigo Wang
2009-07-16  5:09   ` Joe Perches
2009-07-23 21:47 ` Andrew Morton
2009-07-23 22:25   ` Joe Perches

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®