[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <988dfd54-9f11-4ff1-803c-393d168a068b@linux.dev>
Date: Fri, 2 Jan 2026 11:35:39 -0800
From: Yonghong Song <yonghong.song@...ux.dev>
To: WanLi Niu <kiraskyler@....com>, Quentin Monnet <qmo@...nel.org>
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>, Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>, Eduard Zingerman
<eddyz87@...il.com>, Song Liu <song@...nel.org>,
John Fastabend <john.fastabend@...il.com>, KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
Jiri Olsa <jolsa@...nel.org>, Menglong Dong <menglong8.dong@...il.com>,
bpf@...r.kernel.org, linux-kernel@...r.kernel.org,
WanLi Niu <niuwl1@...natelecom.cn>, Menglong Dong <dongml2@...natelecom.cn>
Subject: Re: [PATCH v2 bpf-next] bpftool: Make skeleton C++ compatible with
explicit casts
On 12/31/25 2:29 AM, WanLi Niu wrote:
> From: WanLi Niu <niuwl1@...natelecom.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@...natelecom.cn>
> Co-developed-by: Menglong Dong <dongml2@...natelecom.cn>
> Signed-off-by: Menglong Dong <dongml2@...natelecom.cn>
For llvm22, I hacked with core_kern_overflow.lskel.h and has the following
warning/errors:
In file included from prog_tests/core_kern_overflow.cc:4:
/home/yhs/work/bpf-next/tools/testing/selftests/bpf/core_kern_overflow.lskel.h:65:9: error: assigning to
'struct core_kern_overflow_lskel *' from incompatible type 'void *'
65 | skel = skel_alloc(sizeof(*skel));
| ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/yhs/work/bpf-next/tools/testing/selftests/bpf/core_kern_overflow.lskel.h:68:38: error: arithmetic on pointers to void
68 | skel->ctx.sz = (void *)&skel->links - (void *)skel;
| ~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
Your patch fixed the issue.
But for llvm side, I got the following two more errors:
/home/yhs/work/bpf-next/tools/testing/selftests/bpf/core_kern_overflow.lskel.h:73:15: error: assigning to
'struct core_kern_overflow_lskel__bss *' from incompatible type 'void *'
73 | skel->bss = skel_prep_map_data((void *)data, 4096,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74 | sizeof(data) - 1);
| ~~~~~~~~~~~~~~~~~
/home/yhs/work/bpf-next/tools/testing/selftests/bpf/core_kern_overflow.lskel.h:223:14: error: assigning to
'struct core_kern_overflow_lskel__bss *' from incompatible type 'void *'
223 | skel->bss = skel_finalize_map_data(&skel->maps.bss.initial_value,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
224 | 4096, PROT_READ | PROT_WRITE, skel->maps.bss.map_fd);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
So these two issues can be fixed similar to above skel_alloc() case.
Could you fix both of them?
> ---
> 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 %1$s *)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) {
Powered by blists - more mailing lists