]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bugs/core: Pass down the condition string of WARN_ON_ONCE(cond) warnings to __WARN_FL...
authorIngo Molnar <mingo@kernel.org>
Thu, 15 May 2025 12:46:31 +0000 (14:46 +0200)
committerIngo Molnar <mingo@kernel.org>
Fri, 13 Jun 2025 08:20:52 +0000 (10:20 +0200)
Doing this will allow architecture code to store and print out
this information as part of the WARN_ON and BUG_ON facilities.

The format of the string is '[condition]', for example:

  WARN_ON_ONCE(idx < 0 && ptr);

Will get the '[idx < 0 && ptr]' string literal passed down as 'cond_str'
in __WARN_FLAGS().

Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-arch@vger.kernel.org
Link: https://lore.kernel.org/r/20250515124644.2958810-3-mingo@kernel.org
include/asm-generic/bug.h

index af76e4a04b16c8bea4409de9568e3f7de08315dd..c8e7126bc26e3f0163d6cb6984c93d91b4d9ee8a 100644 (file)
@@ -110,7 +110,7 @@ extern __printf(1, 2) void __warn_printk(const char *fmt, ...);
 #define WARN_ON_ONCE(condition) ({                             \
        int __ret_warn_on = !!(condition);                      \
        if (unlikely(__ret_warn_on))                            \
-               __WARN_FLAGS("",                                \
+               __WARN_FLAGS("["#condition"] ",                 \
                             BUGFLAG_ONCE |                     \
                             BUGFLAG_TAINT(TAINT_WARN));        \
        unlikely(__ret_warn_on);                                \