public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpftool: Make skeleton C++ compatible with explicit casts
@ 2025-12-31  9:25 WanLi Niu
  2025-12-31  9:48 ` bot+bpf-ci
  2025-12-31 10:29 ` [PATCH v2 " WanLi Niu
  0 siblings, 2 replies; 14+ messages in thread
From: WanLi Niu @ 2025-12-31  9:25 UTC (permalink / raw)
  To: Quentin Monnet
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	WanLi Niu, Menglong Dong, bpf, linux-kernel, WanLi Niu,
	Menglong Dong

From: WanLi Niu <niuwl1@chinatelecom.cn>

Fix C++ compilation errors in generated skeleton by adding explicit
pointer casts and using integer subtraction for offset calculation.

error: invalid conversion from 'void*' to 'trace_bpf*' [-fpermissive]
      |         skel = skel_alloc(sizeof(*skel));
      |                ~~~~~~~~~~^~~~~~~~~~~~~~~
      |                          |
      |                          void*

error: invalid use of 'void'
      |         skel->ctx.sz = (void *)&skel->links - (void *)skel;

Signed-off-by: WanLi Niu <niuwl1@chinatelecom.cn>
Co-developed-by: Menglong Dong <dongml2@chinatelecom.cn>
Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>

---
 tools/bpf/bpftool/gen.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
index 993c7d9484a4..71446a776130 100644
--- a/tools/bpf/bpftool/gen.c
+++ b/tools/bpf/bpftool/gen.c
@@ -731,10 +731,10 @@ static int gen_trace(struct bpf_object *obj, const char *obj_name, const char *h
 		{							    \n\
 			struct %1$s *skel;				    \n\
 									    \n\
-			skel = skel_alloc(sizeof(*skel));		    \n\
+			skel = (struct trace_bpf *)skel_alloc(sizeof(*skel));\n\
 			if (!skel)					    \n\
 				goto cleanup;				    \n\
-			skel->ctx.sz = (void *)&skel->links - (void *)skel; \n\
+			skel->ctx.sz = (__u64)&skel->links - (__u64)skel;   \n\
 		",
 		obj_name, opts.data_sz);
 	bpf_object__for_each_map(map, obj) {
-- 
2.39.1


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

end of thread, other threads:[~2026-01-09 19:03 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-31  9:25 [PATCH bpf-next] bpftool: Make skeleton C++ compatible with explicit casts WanLi Niu
2025-12-31  9:48 ` bot+bpf-ci
2025-12-31 10:29 ` [PATCH v2 " WanLi Niu
2026-01-02 19:35   ` Yonghong Song
2026-01-04  2:14   ` [PATCH v3 " WanLi Niu
2026-01-05  5:27     ` Yonghong Song
2026-01-05  7:12     ` [PATCH v4 " WanLi Niu
2026-01-05 10:39       ` Quentin Monnet
2026-01-05 11:50       ` Jose E. Marchesi
2026-01-05 12:53         ` WanLi Niu
2026-01-05 16:05           ` Jose E. Marchesi
2026-01-06  2:31       ` [PATCH v5 " WanLi Niu
2026-01-09 19:00         ` patchwork-bot+netdevbpf
2026-01-06  0:46     ` [PATCH v3 " Andrii Nakryiko

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