* [PATCH bpf-next] bpf: Add __printf attribute to bpf_diag_source()
@ 2026-10-19 19:59 Adrián García Casado
2026-10-20 0:35 ` Alexei Starovoitov
0 siblings, 1 reply; 2+ messages in thread
From: Adrián García Casado @ 2026-10-19 19:59 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Eduard Zingerman
Cc: Kumar Kartikeya Dwivedi, bpf, linux-kernel,
Adrián García Casado
Building kernel/bpf/diagnostics.o with W=1 triggers the following
compiler warning:
kernel/bpf/diagnostics.c:828:9: warning: function 'bpf_diag_source'
might be a candidate for 'gnu_printf' format attribute
[-Wsuggest-attribute=format]
bpf_diag_source() forwards its format string and variadic arguments to
bpf_diag_vfmt(), which is annotated with __printf(2, 0).
Add the missing __printf(4, 5) attribute to bpf_diag_source() to silence
the W=1 warning and enable compile-time format string checking for its
callers.
Signed-off-by: Adrián García Casado <adriangarciacasado42@gmail.com>
---
kernel/bpf/diagnostics.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/bpf/diagnostics.c b/kernel/bpf/diagnostics.c
index 0abbbe177e..2421f52eec 100644
--- a/kernel/bpf/diagnostics.c
+++ b/kernel/bpf/diagnostics.c
@@ -794,6 +794,7 @@ static void diag_print_insn_context(struct bpf_verifier_env *env, u32 insn_idx,
}
}
+__printf(4, 5)
static void bpf_diag_source(struct bpf_verifier_env *env, u32 insn_idx, const char *label,
const char *fmt, ...)
{
--
2.39.5
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH bpf-next] bpf: Add __printf attribute to bpf_diag_source()
2026-10-19 19:59 [PATCH bpf-next] bpf: Add __printf attribute to bpf_diag_source() Adrián García Casado
@ 2026-10-20 0:35 ` Alexei Starovoitov
0 siblings, 0 replies; 2+ messages in thread
From: Alexei Starovoitov @ 2026-10-20 0:35 UTC (permalink / raw)
To: Adrián García Casado, Daniel Borkmann, Andrii Nakryiko,
Eduard Zingerman
Cc: Kumar Kartikeya Dwivedi, bpf, linux-kernel
On Mon, Oct 19, 2026 at 12:59 PM Adrián García Casado <adriangarciacasado42@gmail.com> wrote:
> @@ -794,6 +794,7 @@ static void diag_print_insn_context(struct bpf_verifier_env *env, u32 insn_idx,
> }
> }
>
> +__printf(4, 5)
> static void bpf_diag_source(struct bpf_verifier_env *env, u32 insn_idx, const char *label,
> const char *fmt, ...)
1. This doesn't apply to bpf-next.
2. The warning was fixed a month ago:
commit 7f2b0b57a8d7 ("bpf: Add printf attributes").
pw-bot: cr
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-20 0:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-19 19:59 [PATCH bpf-next] bpf: Add __printf attribute to bpf_diag_source() Adrián García Casado
2026-10-20 0:35 ` Alexei Starovoitov
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®