bpf: Add printf attributes

Building with extra warnings enabled shows a missing printf attribute:

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: b9c5d822f6 ("bpf: Add source and instruction diagnostic context")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20260915213123.2361066-1-arnd@kernel.org
This commit is contained in:
Arnd Bergmann 2026-09-15 23:30:09 +02:00 committed by Andrii Nakryiko
parent a885470df1
commit 7f2b0b57a8

View File

@ -794,8 +794,9 @@ 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,
const char *fmt, ...)
static __printf(4, 5) void bpf_diag_source(struct bpf_verifier_env *env,
u32 insn_idx, const char *label,
const char *fmt, ...)
{
struct bpf_diag_scratch *scratch;
struct bpf_linfo_source *source_lines;