bpf: add printf attributes
PATCH v2 1/1 bpf: add printf attributes
From: Arnd Bergmann <[email protected]>
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.
---
v2 changes:
- only change the one function that needs it
- fix line wrapping
- use correct Fixes tag
--- kernel/bpf/diagnostics.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/bpf/diagnostics.c +3 -2
@@ -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;
Signature · 1 line
2.53.0
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Quoted 9 lines · On Tue, 15 Sep 2026 23:30:09 +0200 you wrote:
From: Arnd Bergmann <[email protected]>
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);[...]
Here is the summary with links:
- [v2] bpf: add printf attributes
https://git.kernel.org/bpf/bpf-next/c/7f2b0b57a8d7
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html