BPF List
 help / color / mirror / Atom feed
* [PATCH v1 1/1] bpf: Mark bpf_stream_vprintk_impl() with __printf() attribute
@ 2025-12-08 15:48 Andy Shevchenko
  2025-12-09  9:14 ` Alexei Starovoitov
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2025-12-08 15:48 UTC (permalink / raw)
  To: Alexei Starovoitov, Kumar Kartikeya Dwivedi, Puranjay Mohan, bpf,
	linux-kernel
  Cc: Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau,
	Eduard Zingerman, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Alan Maguire,
	Mirsad Todorovac, Andy Shevchenko

bpf_stream_vprintk_impl() is using printf() type of format, and compiler
is not happy about them as is:

kernel/bpf/stream.c:241:9: error: function ‘bpf_stream_vprintk_impl’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
  241 |         ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt__str, data.bin_args);
      |         ^~~

Fix the compilation errors by adding __printf() attribute.

Fixes: 5ab154f1463a ("bpf: Introduce BPF standard streams")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 kernel/bpf/stream.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/bpf/stream.c b/kernel/bpf/stream.c
index 0b6bc3f30335..4bff72e3c16f 100644
--- a/kernel/bpf/stream.c
+++ b/kernel/bpf/stream.c
@@ -212,6 +212,7 @@ __bpf_kfunc_start_defs();
  * Avoid using enum bpf_stream_id so that kfunc users don't have to pull in the
  * enum in headers.
  */
+__printf(2, 0)
 __bpf_kfunc int bpf_stream_vprintk_impl(int stream_id, const char *fmt__str, const void *args,
 					u32 len__sz, void *aux__prog)
 {
-- 
2.50.1


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

end of thread, other threads:[~2025-12-09  9:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-08 15:48 [PATCH v1 1/1] bpf: Mark bpf_stream_vprintk_impl() with __printf() attribute Andy Shevchenko
2025-12-09  9:14 ` Alexei Starovoitov

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