mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] bpf: add printf attributes
@ 2026-09-15 20:21 Arnd Bergmann
  2026-09-15 21:11 ` bot+bpf-ci
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2026-09-15 20:21 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Eduard Zingerman, Kumar Kartikeya Dwivedi
  Cc: Arnd Bergmann, Martin KaFai Lau, Song Liu, Yonghong Song,
	Jiri Olsa, Emil Tsalapatis, Ihor Solodrai, Amery Hung, Kees Cook,
	bpf, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

Building with extra warnings enabled shows some missing printf attributes:

kernel/bpf/diagnostics.c: In function 'bpf_diag_source':
kernel/bpf/diagnostics.c:828:9: error: function 'bpf_diag_source' might be a candidate for 'gnu_printf' format attribute [-Werror=suggest-attribute=format]
  828 |         msg = bpf_diag_vfmt(env, fmt, args);

Add these to shut up the warning and allow the compiler to check the
format strings.

Fixes: a8f427835394 ("bpf: Report Program Structure CFG errors")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 kernel/bpf/diagnostics.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/bpf/diagnostics.c b/kernel/bpf/diagnostics.c
index a2cac59c6639..b069fe73d3dc 100644
--- a/kernel/bpf/diagnostics.c
+++ b/kernel/bpf/diagnostics.c
@@ -291,7 +291,7 @@ char *bpf_diag_fmt_buf(struct bpf_verifier_env *env, size_t size)
 	return buf;
 }
 
-const char *bpf_diag_vfmt(struct bpf_verifier_env *env, const char *fmt, va_list args)
+__printf(2, 0) const char *bpf_diag_vfmt(struct bpf_verifier_env *env, const char *fmt, va_list args)
 {
 	va_list copy;
 	char *buf;
@@ -309,7 +309,7 @@ const char *bpf_diag_vfmt(struct bpf_verifier_env *env, const char *fmt, va_list
 	return buf ?: "";
 }
 
-const char *bpf_diag_fmt(struct bpf_verifier_env *env, const char *fmt, ...)
+__printf(2, 3) const char *bpf_diag_fmt(struct bpf_verifier_env *env, const char *fmt, ...)
 {
 	const char *buf;
 	va_list args;
@@ -794,7 +794,7 @@ static void diag_print_insn_context(struct bpf_verifier_env *env, u32 insn_idx,
 	}
 }
 
-static void bpf_diag_source(struct bpf_verifier_env *env, u32 insn_idx, const char *label,
+__printf(4, 5) static void bpf_diag_source(struct bpf_verifier_env *env, u32 insn_idx, const char *label,
 			    const char *fmt, ...)
 {
 	struct bpf_diag_scratch *scratch;
-- 
2.53.0


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

end of thread, other threads:[~2026-09-15 21:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-15 20:21 [PATCH] bpf: add printf attributes Arnd Bergmann
2026-09-15 21:11 ` bot+bpf-ci

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®