All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] libbpf: Fix macro redefined
@ 2025-07-16  8:06 Feng Yang
  2025-07-16 15:24 ` Yonghong Song
  0 siblings, 1 reply; 2+ messages in thread
From: Feng Yang @ 2025-07-16  8:06 UTC (permalink / raw)
  To: ast, daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, memxor
  Cc: bpf, linux-kernel

From: Feng Yang <yangfeng@kylinos.cn>

When compiling a program that include <linux/bpf.h> and <bpf/bpf_helpers.h>, (For example: make samples/bpf)
the following warning will be generated:
In file included from tcp_dumpstats_kern.c:7:
samples/bpf/libbpf/include/bpf/bpf_helpers.h:321:9: warning: 'bpf_stream_printk' macro redefined [-Wmacro-redefined]
  321 | #define bpf_stream_printk(stream_id, fmt, args...)                              \
      |         ^
include/linux/bpf.h:3626:9: note: previous definition is here
 3626 | #define bpf_stream_printk(ss, ...) bpf_stream_stage_printk(&ss, __VA_ARGS__)
      |         ^

Therefore, similar to bpf_vprintk,
two underscores are added to distinguish it from bpf_stream_printk in bpf.h.

Fixes: 21a3afc76a31 ("libbpf: Add bpf_stream_printk() macro")
Signed-off-by: Feng Yang <yangfeng@kylinos.cn>
---
 tools/lib/bpf/bpf_helpers.h                | 2 +-
 tools/testing/selftests/bpf/progs/stream.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/lib/bpf/bpf_helpers.h b/tools/lib/bpf/bpf_helpers.h
index 80c028540656..56391a7bee48 100644
--- a/tools/lib/bpf/bpf_helpers.h
+++ b/tools/lib/bpf/bpf_helpers.h
@@ -318,7 +318,7 @@ enum libbpf_tristate {
 extern int bpf_stream_vprintk(int stream_id, const char *fmt__str, const void *args,
 			      __u32 len__sz, void *aux__prog) __weak __ksym;
 
-#define bpf_stream_printk(stream_id, fmt, args...)				\
+#define __bpf_stream_printk(stream_id, fmt, args...)				\
 ({										\
 	static const char ___fmt[] = fmt;					\
 	unsigned long long ___param[___bpf_narg(args)];				\
diff --git a/tools/testing/selftests/bpf/progs/stream.c b/tools/testing/selftests/bpf/progs/stream.c
index 35790897dc87..1d0663d56c0a 100644
--- a/tools/testing/selftests/bpf/progs/stream.c
+++ b/tools/testing/selftests/bpf/progs/stream.c
@@ -29,7 +29,7 @@ int stream_exhaust(void *ctx)
 	/* Use global variable for loop convergence. */
 	size = 0;
 	bpf_repeat(BPF_MAX_LOOPS) {
-		if (bpf_stream_printk(BPF_STDOUT, _STR) == -ENOSPC && size == 99954)
+		if (__bpf_stream_printk(BPF_STDOUT, _STR) == -ENOSPC && size == 99954)
 			return 0;
 		size += sizeof(_STR) - 1;
 	}
@@ -72,7 +72,7 @@ SEC("syscall")
 __success __retval(0)
 int stream_syscall(void *ctx)
 {
-	bpf_stream_printk(BPF_STDOUT, "foo");
+	__bpf_stream_printk(BPF_STDOUT, "foo");
 	return 0;
 }
 
-- 
2.43.0


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

end of thread, other threads:[~2025-07-16 15:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-16  8:06 [PATCH bpf-next] libbpf: Fix macro redefined Feng Yang
2025-07-16 15:24 ` Yonghong Song

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.