From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-187.mta1.migadu.com (out-187.mta1.migadu.com [95.215.58.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F64E1B81CA for ; Fri, 2 Jan 2026 19:36:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767382563; cv=none; b=bW++Ut0D9g74id68iLlDk/twTOzM1yHuBBqiRu/bPSSZb6JQf/9cDJWrGB49vx35gnhBSkft5/WY7tywo0LI62zPmGfdPVtYct84PY3k+iplmZ/szsNjTklhuZmjHP4WEbJqlmRb6xVxsgTL3YdGt8YhJHa02xmxinGxn0M2WjA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767382563; c=relaxed/simple; bh=3cO+VfBib8WchVUvUBd8cQwhcsE6+hlvGSo2JoXPBig=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=l7yPfCHI72niIEUBddkP73gB5eHctBF71OuZVf8SbEhGKrTgybwE1imJmJRKsFF3tkCQQOhzIKSN48+P05MjK8mkLKOIgEMTd8gHV56NmJrdKYTi/8aJs3aQyBNtKHmkseFjl0VX2wU1YkvI+zGyZOZe+JQnLmQ4+H2ZnZ8LY/Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=q9jTOR7p; arc=none smtp.client-ip=95.215.58.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="q9jTOR7p" Message-ID: <988dfd54-9f11-4ff1-803c-393d168a068b@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1767382558; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LqGMLYsOH1eK6u8yWgEXbjw4Z87nIOH6/YxoX0KJi5M=; b=q9jTOR7pz3CbrAo6xvwFmaku8zlEbvtGB3mvUFNSGGdcBxIielc+oxMT0di+Ug7MkkVWoU Wg5P8GYG0Qolxrpon7hXILg3uwHKw0757LPNoKzaETgkx5VqfNTA5zm7lrz4gv0rue2qXx 7uictRfLcR/zyRZbuPuz0lQEnZdNL78= Date: Fri, 2 Jan 2026 11:35:39 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH v2 bpf-next] bpftool: Make skeleton C++ compatible with explicit casts Content-Language: en-GB To: WanLi Niu , Quentin Monnet Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Menglong Dong , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, WanLi Niu , Menglong Dong References: <20251231092541.3352-1-kiraskyler@163.com> <20251231102929.3843-1-kiraskyler@163.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yonghong Song In-Reply-To: <20251231102929.3843-1-kiraskyler@163.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On 12/31/25 2:29 AM, WanLi Niu wrote: > From: WanLi Niu > > 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 > Co-developed-by: Menglong Dong > Signed-off-by: Menglong Dong 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) {