Skip to content

Commit b607e70

Browse files
joshtripletttorvalds
authored andcommitted
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 <[email protected]> Acked-by: Arnd Bergmann <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 5d2acfc commit b607e70

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

include/asm-generic/bug.h

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -106,33 +106,6 @@ extern void warn_slowpath_null(const char *file, const int line);
106106
unlikely(__ret_warn_on); \
107107
})
108108

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-
136109
#define WARN_ON_ONCE(condition) ({ \
137110
static bool __section(.data.unlikely) __warned; \
138111
int __ret_warn_once = !!(condition); \
@@ -163,6 +136,36 @@ extern void warn_slowpath_null(const char *file, const int line);
163136
unlikely(__ret_warn_once); \
164137
})
165138

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+
166169
/*
167170
* WARN_ON_SMP() is for cases that the warning is either
168171
* meaningless for !SMP or may even cause failures.

0 commit comments

Comments
 (0)