Re: [PATCH bpf-next] bpftool: Make skeleton C++ compatible with explicit casts

From: bot+bpf-ci

Date: Wed Dec 31 2025 - 04:48:21 EST


> 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\
^^^^^^^^^

Should this cast use (struct %1$s *) instead of (struct trace_bpf *)?

The variable skel is declared as "struct %1$s *skel" where %1$s is replaced
with obj_name, but the cast hardcodes "trace_bpf" regardless of what skeleton
is being generated. This would cause C++ compilation errors for any BPF
object with a name other than trace_bpf.

For comparison, the non-loader skeleton at do_skeleton() correctly uses
"(struct %1$s *)calloc()" to match the skeleton name.


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/20616299845