Skip to content

Commit 4f1b701

Browse files
author
Peter Zijlstra
committed
x86/bug: Use BUG_FORMAT for DEBUG_BUGVERBOSE_DETAILED
Since we have an explicit format string, use it for the condition string instead of frobbing it in the file string. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://patch.msgid.link/20251110115758.097401406@infradead.org
1 parent 0a52d33 commit 4f1b701

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

arch/x86/include/asm/bug.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,19 @@
7474
".popsection\n" \
7575
extra
7676

77+
#ifdef CONFIG_DEBUG_BUGVERBOSE_DETAILED
78+
#define WARN_CONDITION_STR(cond_str) cond_str
79+
#else
80+
#define WARN_CONDITION_STR(cond_str) NULL
81+
#endif
82+
7783
#define _BUG_FLAGS(cond_str, ins, flags, extra) \
7884
do { \
7985
asm_inline volatile(_BUG_FLAGS_ASM(ins, "%c[fmt]", "%c[file]", \
8086
"%c[line]", "%c[fl]", \
8187
"%c[size]", extra) \
82-
: : [fmt] "i" (NULL), \
83-
[file] "i" (WARN_CONDITION_STR(cond_str) __FILE__), \
88+
: : [fmt] "i" (WARN_CONDITION_STR(cond_str)), \
89+
[file] "i" (__FILE__), \
8490
[line] "i" (__LINE__), \
8591
[fl] "i" (flags), \
8692
[size] "i" (sizeof(struct bug_entry))); \

include/asm-generic/bug.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818
#define BUG_GET_TAINT(bug) ((bug)->flags >> 8)
1919
#endif
2020

21+
#ifndef WARN_CONDITION_STR
2122
#ifdef CONFIG_DEBUG_BUGVERBOSE_DETAILED
22-
# define WARN_CONDITION_STR(cond_str) cond_str
23+
# define WARN_CONDITION_STR(cond_str) "[" cond_str "] "
2324
#else
2425
# define WARN_CONDITION_STR(cond_str)
2526
#endif
27+
#endif /* WARN_CONDITION_STR */
2628

2729
#ifndef __ASSEMBLY__
2830
#include <linux/panic.h>
@@ -107,7 +109,7 @@ extern __printf(1, 2) void __warn_printk(const char *fmt, ...);
107109
#define WARN_ON(condition) ({ \
108110
int __ret_warn_on = !!(condition); \
109111
if (unlikely(__ret_warn_on)) \
110-
__WARN_FLAGS("["#condition"] ", \
112+
__WARN_FLAGS(#condition, \
111113
BUGFLAG_TAINT(TAINT_WARN)); \
112114
unlikely(__ret_warn_on); \
113115
})
@@ -117,7 +119,7 @@ extern __printf(1, 2) void __warn_printk(const char *fmt, ...);
117119
#define WARN_ON_ONCE(condition) ({ \
118120
int __ret_warn_on = !!(condition); \
119121
if (unlikely(__ret_warn_on)) \
120-
__WARN_FLAGS("["#condition"] ", \
122+
__WARN_FLAGS(#condition, \
121123
BUGFLAG_ONCE | \
122124
BUGFLAG_TAINT(TAINT_WARN)); \
123125
unlikely(__ret_warn_on); \

0 commit comments

Comments
 (0)