aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-generic/bug.h
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2006-09-29 04:59:06 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-29 12:18:06 -0400
commit684f978347deb42d180373ac4c427f82ef963171 (patch)
treedb9025d8c6b267565c7110e09b16193957186a48 /include/asm-generic/bug.h
parent6299a2dec89d22940e36832f15c0addfb77e6910 (diff)
[PATCH] Let WARN_ON/WARN_ON_ONCE return the condition
Letting WARN_ON/WARN_ON_ONCE return the condition means that you could do if (WARN_ON(blah)) { handle_impossible_case } Rather than if (unlikely(blah)) { WARN_ON(1) handle_impossible_case } I checked all the newly added WARN_ON_ONCE users and none of them test the return status so we can still change it. [akpm@osdl.org: warning fix] [akpm@osdl.org: build fix] Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/asm-generic/bug.h')
-rw-r--r--include/asm-generic/bug.h32
1 files changed, 16 insertions, 16 deletions
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 8ceab7bcd8b4..a5250895155e 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -16,12 +16,15 @@
16#endif 16#endif
17 17
18#ifndef HAVE_ARCH_WARN_ON 18#ifndef HAVE_ARCH_WARN_ON
19#define WARN_ON(condition) do { \ 19#define WARN_ON(condition) ({ \
20 if (unlikely((condition)!=0)) { \ 20 typeof(condition) __ret_warn_on = (condition); \
21 printk("BUG: warning at %s:%d/%s()\n", __FILE__, __LINE__, __FUNCTION__); \ 21 if (unlikely(__ret_warn_on)) { \
22 dump_stack(); \ 22 printk("BUG: warning at %s:%d/%s()\n", __FILE__, \
23 } \ 23 __LINE__, __FUNCTION__); \
24} while (0) 24 dump_stack(); \
25 } \
26 unlikely(__ret_warn_on); \
27})
25#endif 28#endif
26 29
27#else /* !CONFIG_BUG */ 30#else /* !CONFIG_BUG */
@@ -34,21 +37,18 @@
34#endif 37#endif
35 38
36#ifndef HAVE_ARCH_WARN_ON 39#ifndef HAVE_ARCH_WARN_ON
37#define WARN_ON(condition) do { if (condition) ; } while(0) 40#define WARN_ON(condition) unlikely((condition))
38#endif 41#endif
39#endif 42#endif
40 43
41#define WARN_ON_ONCE(condition) \ 44#define WARN_ON_ONCE(condition) ({ \
42({ \
43 static int __warn_once = 1; \ 45 static int __warn_once = 1; \
44 int __ret = 0; \ 46 typeof(condition) __ret_warn_once = (condition);\
45 \ 47 \
46 if (unlikely((condition) && __warn_once)) { \ 48 if (likely(__warn_once)) \
47 __warn_once = 0; \ 49 if (WARN_ON(__ret_warn_once)) \
48 WARN_ON(1); \ 50 __warn_once = 0; \
49 __ret = 1; \ 51 unlikely(__ret_warn_once); \
50 } \
51 __ret; \
52}) 52})
53 53
54#ifdef CONFIG_SMP 54#ifdef CONFIG_SMP