aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2014-04-07 18:39:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-07 19:36:10 -0400
commitb607e70ec6a982fb4e69c4949b5ec57341cf0d94 (patch)
tree09daa75d7430b4a51d85410280ec2a12c591875a
parent5d2acfc7b974bbd3858b4dd3f2cdc6362dd8843a (diff)
bug: when !CONFIG_BUG, simplify WARN_ON_ONCE and family
When !CONFIG_BUG, WARN_ON and family become simple passthroughs of their condition argument; however, WARN_ON_ONCE and family still have conditions and a boolean to detect one-time invocation, even though the warning they'd emit doesn't exist. Make the existing definitions conditional on CONFIG_BUG, and add definitions for !CONFIG_BUG that map to the passthrough versions of WARN and WARN_ON. This saves 4.4k on a minimized configuration (smaller than allnoconfig), and 20.6k with defconfig plus CONFIG_BUG=n. Signed-off-by: Josh Triplett <josh@joshtriplett.org> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/asm-generic/bug.h57
1 files changed, 30 insertions, 27 deletions
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 7d10f962aa13..7ecd398aebf0 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -106,33 +106,6 @@ extern void warn_slowpath_null(const char *file, const int line);
106 unlikely(__ret_warn_on); \ 106 unlikely(__ret_warn_on); \
107}) 107})
108 108
109#else /* !CONFIG_BUG */
110#ifndef HAVE_ARCH_BUG
111#define BUG() do {} while(0)
112#endif
113
114#ifndef HAVE_ARCH_BUG_ON
115#define BUG_ON(condition) do { if (condition) ; } while(0)
116#endif
117
118#ifndef HAVE_ARCH_WARN_ON
119#define WARN_ON(condition) ({ \
120 int __ret_warn_on = !!(condition); \
121 unlikely(__ret_warn_on); \
122})
123#endif
124
125#ifndef WARN
126#define WARN(condition, format...) ({ \
127 int __ret_warn_on = !!(condition); \
128 unlikely(__ret_warn_on); \
129})
130#endif
131
132#define WARN_TAINT(condition, taint, format...) WARN_ON(condition)
133
134#endif
135
136#define WARN_ON_ONCE(condition) ({ \ 109#define WARN_ON_ONCE(condition) ({ \
137 static bool __section(.data.unlikely) __warned; \ 110 static bool __section(.data.unlikely) __warned; \
138 int __ret_warn_once = !!(condition); \ 111 int __ret_warn_once = !!(condition); \
@@ -163,6 +136,36 @@ extern void warn_slowpath_null(const char *file, const int line);
163 unlikely(__ret_warn_once); \ 136 unlikely(__ret_warn_once); \
164}) 137})
165 138
139#else /* !CONFIG_BUG */
140#ifndef HAVE_ARCH_BUG
141#define BUG() do {} while(0)
142#endif
143
144#ifndef HAVE_ARCH_BUG_ON
145#define BUG_ON(condition) do { if (condition) ; } while(0)
146#endif
147
148#ifndef HAVE_ARCH_WARN_ON
149#define WARN_ON(condition) ({ \
150 int __ret_warn_on = !!(condition); \
151 unlikely(__ret_warn_on); \
152})
153#endif
154
155#ifndef WARN
156#define WARN(condition, format...) ({ \
157 int __ret_warn_on = !!(condition); \
158 unlikely(__ret_warn_on); \
159})
160#endif
161
162#define WARN_ON_ONCE(condition) WARN_ON(condition)
163#define WARN_ONCE(condition, format...) WARN(condition, format)
164#define WARN_TAINT(condition, taint, format...) WARN(condition, format)
165#define WARN_TAINT_ONCE(condition, taint, format...) WARN(condition, format)
166
167#endif
168
166/* 169/*
167 * WARN_ON_SMP() is for cases that the warning is either 170 * WARN_ON_SMP() is for cases that the warning is either
168 * meaningless for !SMP or may even cause failures. 171 * meaningless for !SMP or may even cause failures.