diff options
author | Arjan van de Ven <arjan@linux.intel.com> | 2008-07-25 04:45:53 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-25 13:53:29 -0400 |
commit | a8f18b909c0a3f22630846207035c8b84bb252b8 (patch) | |
tree | 72a2dee787b9d077cc24f5cf7392b071401506ec /include | |
parent | b6c63937001889af6fe431aaba97e59d04e028e7 (diff) |
Add a WARN() macro; this is WARN_ON() + printk arguments
Add a WARN() macro that acts like WARN_ON(), with the added feature that it
takes a printk like argument that is printed as part of the warning message.
[akpm@linux-foundation.org: fix printk arguments]
[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Cc: Greg KH <greg@kroah.com>
Cc: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/bug.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index 2632328d8646..a346e744e770 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h | |||
@@ -34,9 +34,14 @@ struct bug_entry { | |||
34 | #ifndef __WARN | 34 | #ifndef __WARN |
35 | #ifndef __ASSEMBLY__ | 35 | #ifndef __ASSEMBLY__ |
36 | extern void warn_on_slowpath(const char *file, const int line); | 36 | extern void warn_on_slowpath(const char *file, const int line); |
37 | extern void warn_slowpath(const char *file, const int line, | ||
38 | const char *fmt, ...) __attribute__((format(printf, 3, 4))); | ||
37 | #define WANT_WARN_ON_SLOWPATH | 39 | #define WANT_WARN_ON_SLOWPATH |
38 | #endif | 40 | #endif |
39 | #define __WARN() warn_on_slowpath(__FILE__, __LINE__) | 41 | #define __WARN() warn_on_slowpath(__FILE__, __LINE__) |
42 | #define __WARN_printf(arg...) warn_slowpath(__FILE__, __LINE__, arg) | ||
43 | #else | ||
44 | #define __WARN_printf(arg...) __WARN() | ||
40 | #endif | 45 | #endif |
41 | 46 | ||
42 | #ifndef WARN_ON | 47 | #ifndef WARN_ON |
@@ -48,6 +53,15 @@ extern void warn_on_slowpath(const char *file, const int line); | |||
48 | }) | 53 | }) |
49 | #endif | 54 | #endif |
50 | 55 | ||
56 | #ifndef WARN | ||
57 | #define WARN(condition, format...) ({ \ | ||
58 | int __ret_warn_on = !!(condition); \ | ||
59 | if (unlikely(__ret_warn_on)) \ | ||
60 | __WARN_printf(format); \ | ||
61 | unlikely(__ret_warn_on); \ | ||
62 | }) | ||
63 | #endif | ||
64 | |||
51 | #else /* !CONFIG_BUG */ | 65 | #else /* !CONFIG_BUG */ |
52 | #ifndef HAVE_ARCH_BUG | 66 | #ifndef HAVE_ARCH_BUG |
53 | #define BUG() | 67 | #define BUG() |
@@ -63,6 +77,14 @@ extern void warn_on_slowpath(const char *file, const int line); | |||
63 | unlikely(__ret_warn_on); \ | 77 | unlikely(__ret_warn_on); \ |
64 | }) | 78 | }) |
65 | #endif | 79 | #endif |
80 | |||
81 | #ifndef WARN | ||
82 | #define WARN(condition, format...) ({ \ | ||
83 | int __ret_warn_on = !!(condition); \ | ||
84 | unlikely(__ret_warn_on); \ | ||
85 | }) | ||
86 | #endif | ||
87 | |||
66 | #endif | 88 | #endif |
67 | 89 | ||
68 | #define WARN_ON_ONCE(condition) ({ \ | 90 | #define WARN_ON_ONCE(condition) ({ \ |