Skip to content

Commit 26e7139

Browse files
arndbgregkh
authored andcommitted
bug: avoid format attribute warning for clang as well
[ Upstream commit 2598ab9 ] Like gcc, clang-22 now also warns about a function that it incorrectly identifies as a printf-style format: lib/bug.c:190:22: error: diagnostic behavior may be improved by adding the 'format(printf, 1, 0)' attribute to the declaration of '__warn_printf' [-Werror,-Wmissing-format-attribute] 179 | static void __warn_printf(const char *fmt, struct pt_regs *regs) | __attribute__((format(printf, 1, 0))) 180 | { 181 | if (!fmt) 182 | return; 183 | 184 | #ifdef HAVE_ARCH_BUG_FORMAT_ARGS 185 | if (regs) { 186 | struct arch_va_list _args; 187 | va_list *args = __warn_args(&_args, regs); 188 | 189 | if (args) { 190 | vprintk(fmt, *args); | ^ Revert the change that added a gcc-specific workaround, and instead add the generic annotation that avoid the warning. Link: https://lkml.kernel.org/r/20260323205534.1284284-1-arnd@kernel.org Fixes: d36067d ("bug: Hush suggest-attribute=format for __warn_printf()") Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Suggested-by: Brendan Jackman <jackmanb@google.com> Link: https://lore.kernel.org/all/20251208141618.2805983-1-andriy.shevchenko@linux.intel.com/T/#u Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Brendan Jackman <jackmanb@google.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Bill Wendling <morbo@google.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Justin Stitt <justinstitt@google.com> Cc: Nathan Chancellor <nathan@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent be6b973 commit 26e7139

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

lib/bug.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,8 @@ struct bug_entry *find_bug(unsigned long bugaddr)
173173
return module_find_bug(bugaddr);
174174
}
175175

176-
__diag_push();
177-
__diag_ignore(GCC, all, "-Wsuggest-attribute=format",
178-
"Not a valid __printf() conversion candidate.");
179-
static void __warn_printf(const char *fmt, struct pt_regs *regs)
176+
static __printf(1, 0)
177+
void __warn_printf(const char *fmt, struct pt_regs *regs)
180178
{
181179
if (!fmt)
182180
return;
@@ -195,7 +193,6 @@ static void __warn_printf(const char *fmt, struct pt_regs *regs)
195193

196194
printk("%s", fmt);
197195
}
198-
__diag_pop();
199196

200197
static enum bug_trap_type __report_bug(struct bug_entry *bug, unsigned long bugaddr, struct pt_regs *regs)
201198
{

0 commit comments

Comments
 (0)