All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bug: hush suggest-attribute=format for __warn_printf()
@ 2025-12-07  3:53 Brendan Jackman
  2025-12-08  8:38 ` Peter Zijlstra
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Brendan Jackman @ 2025-12-07  3:53 UTC (permalink / raw)
  To: Andrew Morton, Peter Zijlstra
  Cc: linux-kernel, kees, acarmina, jpoimboe, mark.rutland,
	maciej.wieczor-retman, Brendan Jackman

Recent additions to this function cause GCC 14.3.0 to get excited and
suggest a missing attribute:

lib/bug.c: In function ‘__warn_printf’:
lib/bug.c:187:25: error: function ‘__warn_printf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
  187 |                         vprintk(fmt, *args);
      |                         ^~~~~~~

Disable the diagnostic locally, following the pattern used for stuff
like va_format().

Fixes: 5c47b7f3d1a9 ("bug: Add BUG_FORMAT_ARGS infrastructure")
Signed-off-by: Brendan Jackman <jackmanb@google.com>
---
 lib/bug.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/bug.c b/lib/bug.c
index edd9041f89f3aa613af71e4f107b52a4f4dc71f4..051891f874439d66f907e043cf52b954b3ea564b 100644
--- a/lib/bug.c
+++ b/lib/bug.c
@@ -173,6 +173,9 @@ struct bug_entry *find_bug(unsigned long bugaddr)
 	return module_find_bug(bugaddr);
 }
 
+__diag_push();
+__diag_ignore(GCC, all, "-Wsuggest-attribute=format",
+	      "Not a valid __printf() conversion candidate.");
 static void __warn_printf(const char *fmt, struct pt_regs *regs)
 {
 	if (!fmt)
@@ -192,6 +195,7 @@ static void __warn_printf(const char *fmt, struct pt_regs *regs)
 
 	printk("%s", fmt);
 }
+__diag_pop();
 
 static enum bug_trap_type __report_bug(struct bug_entry *bug, unsigned long bugaddr, struct pt_regs *regs)
 {

---
base-commit: 5e8f8a25efb277ac6f61f553f0c533ff1402bd7c
change-id: 20251207-warn-printf-gcc-8da08c251c1c

Best regards,
-- 
Brendan Jackman <jackmanb@google.com>


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-12-16 12:43 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-07  3:53 [PATCH] bug: hush suggest-attribute=format for __warn_printf() Brendan Jackman
2025-12-08  8:38 ` Peter Zijlstra
2025-12-08  8:50   ` Brendan Jackman
2025-12-08  8:58     ` Peter Zijlstra
2025-12-09  9:16 ` [tip: core/urgent] bug: Hush " tip-bot2 for Brendan Jackman
2025-12-12  9:10 ` tip-bot2 for Brendan Jackman
2025-12-12  9:29 ` tip-bot2 for Brendan Jackman
2025-12-16  4:24 ` [PATCH] bug: hush " Andrew Morton
2025-12-16  8:49   ` Peter Zijlstra
2025-12-16  9:16     ` Brendan Jackman
2025-12-16 12:36       ` David Laight
2025-12-16 12:43         ` Brendan Jackman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.