From: Brendan Jackman <jackmanb@google.com>
To: Arnd Bergmann <arnd@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Nathan Chancellor <nathan@kernel.org>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
Brendan Jackman <jackmanb@google.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
<linux-kernel@vger.kernel.org>, <llvm@lists.linux.dev>
Subject: Re: [PATCH] bug: shut up format attribute warning for clang as well
Date: Mon, 23 Mar 2026 10:54:25 +0000 [thread overview]
Message-ID: <DHA3U3U4ZZXQ.2RPHOFNQJ70JQ@google.com> (raw)
In-Reply-To: <20260320211528.2474389-1-arnd@kernel.org>
On Fri Mar 20, 2026 at 9:14 PM UTC, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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);
> | ^
>
> Turn off this warning for all compilers and versions.
>
> Fixes: d36067d6ea00 ("bug: Hush suggest-attribute=format for __warn_printf()")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> lib/bug.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/lib/bug.c b/lib/bug.c
> index bbc301097749..374feb144f0b 100644
> --- a/lib/bug.c
> +++ b/lib/bug.c
> @@ -174,8 +174,7 @@ struct bug_entry *find_bug(unsigned long bugaddr)
> }
>
> __diag_push();
> -__diag_ignore(GCC, all, "-Wsuggest-attribute=format",
> - "Not a valid __printf() conversion candidate.");
> +__diag_ignore_all("-Wmissing-format-attribute", "Not a valid __printf() conversion candidate.");
> static void __warn_printf(const char *fmt, struct pt_regs *regs)
> {
> if (!fmt)
There is actually a superior fix for this warning that Andy Schevchenko
posted here (mine just happened to get merged first):
https://lore.kernel.org/all/20251208141618.2805983-1-andriy.shevchenko@linux.intel.com/T/#u
Should we just switch over to that? Looks like it should work for both
compilers.
next prev parent reply other threads:[~2026-03-23 10:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 21:14 [PATCH] bug: shut up format attribute warning for clang as well Arnd Bergmann
2026-03-21 0:08 ` Nathan Chancellor
2026-03-23 10:54 ` Brendan Jackman [this message]
2026-03-23 15:38 ` Arnd Bergmann
2026-03-23 20:45 ` Andrew Morton
2026-03-23 20:56 ` Arnd Bergmann
2026-03-24 11:26 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DHA3U3U4ZZXQ.2RPHOFNQJ70JQ@google.com \
--to=jackmanb@google.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=justinstitt@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mingo@kernel.org \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox