[Bpf] Re: [PATCH] bpftool: Fix -Wuninitialized-const-pointer warnings with clang >= 21
Quentin Monnet <qmo@kernel.org> Wed, 17 September 2025 09:37 UTC
Return-Path: <qmo@kernel.org>
X-Original-To: bpf@mail2.ietf.org
Delivered-To: bpf@mail2.ietf.org
Received: from localhost (localhost [127.0.0.1]) by mail2.ietf.org (Postfix) with ESMTP id EC14464248EC for <bpf@mail2.ietf.org>; Wed, 17 Sep 2025 02:37:12 -0700 (PDT)
X-Virus-Scanned: amavisd-new at ietf.org
X-Spam-Flag: NO
X-Spam-Score: -2.101
X-Spam-Level:
X-Spam-Status: No, score=-2.101 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: mail2.ietf.org (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org
Received: from mail2.ietf.org ([166.84.6.31]) by localhost (mail2.ietf.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FJotiGnWSSBi for <bpf@mail2.ietf.org>; Wed, 17 Sep 2025 02:37:12 -0700 (PDT)
Received: from sea.source.kernel.org (sea.source.kernel.org [IPv6:2600:3c0a:e001:78e:0:1991:8:25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail2.ietf.org (Postfix) with ESMTPS id 85F1D64248E2 for <bpf@ietf.org>; Wed, 17 Sep 2025 02:37:12 -0700 (PDT)
Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id A8E7D40672; Wed, 17 Sep 2025 09:37:04 +0000 (UTC)
Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DE3AC4CEF0; Wed, 17 Sep 2025 09:37:03 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758101824; bh=HSkIKVqUkPJ1U2F4w09spi2yY1V93LDyXcKzcdjwe+g=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=GLKdxjwYnB7YIo8gsl0Z7Tr6kfMSepGPyoIewvSczQ07a/0cuLD+Wdeu5tdKNYsFA p1ZWG80Evnu9/nwBMSOljZp0M1l0ZcplF0J+J4Gy5bGXSmOZrmu/RsXi0DBf2JNTP+ rmY7jV5KmmiltjKArYDBscgLsXtFxYsJEhM+PzX653dxwvS/VMcFICilAq3H7WFlQz RB0qTKXATcnPdgsIt8pxGZ6t6/fD1Pmd6eXNc/sMH54CwnUS1yGEC2v2/5kdNA8hRC BMCURa4mjrTtTZ5G2NfTWaNUwceXG2ka4TjlecDl2732v/yPhIWgm+dNDCR6nM4aGd w3T4nnpdL6bXg==
Message-ID: <028e2421-ddc4-489f-a27c-dabf908ccc26@kernel.org>
Date: Wed, 17 Sep 2025 10:37:02 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
To: Tom Stellard <tstellar=40redhat.com@dmarc.ietf.org>, bpf@ietf.org
References: <20250917061123.233534-1-tstellar@redhat.com>
From: Quentin Monnet <qmo@kernel.org>
Content-Language: en-GB
In-Reply-To: <20250917061123.233534-1-tstellar@redhat.com>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
Message-ID-Hash: GNL3DBDQ3M55YH6PLNL2GLYFFZ57ARDQ
X-Message-ID-Hash: GNL3DBDQ3M55YH6PLNL2GLYFFZ57ARDQ
X-MailFrom: qmo@kernel.org
X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header
CC: Tom Stellard <tstellar@redhat.com>
X-Mailman-Version: 3.3.9rc6
Precedence: list
Subject: [Bpf] Re: [PATCH] bpftool: Fix -Wuninitialized-const-pointer warnings with clang >= 21
List-Id: Discussion of BPF/eBPF standardization efforts within the IETF <bpf.ietf.org>
Archived-At: <https://mailarchive.ietf.org/arch/msg/bpf/Tl6u4uykYunUXJb8ZdP-B8a37Y8>
List-Archive: <https://mailarchive.ietf.org/arch/browse/bpf>
List-Help: <mailto:bpf-request@ietf.org?subject=help>
List-Owner: <mailto:bpf-owner@ietf.org>
List-Post: <mailto:bpf@ietf.org>
List-Subscribe: <mailto:bpf-join@ietf.org>
List-Unsubscribe: <mailto:bpf-leave@ietf.org>
2025-09-16 23:11 UTC-0700 ~ Tom Stellard <tstellar=40redhat.com@dmarc.ietf.org> > This fixes the build with -Werror -Wall. > > btf_dumper.c:71:31: error: variable 'finfo' is uninitialized when passed as a const pointer argument here [-Werror,-Wuninitialized-const-pointer] > 71 | info.func_info = ptr_to_u64(&finfo); > | ^~~~~ > > prog.c:2294:31: error: variable 'func_info' is uninitialized when passed as a const pointer argument here [-Werror,-Wuninitialized-const-pointer] > 2294 | info.func_info = ptr_to_u64(&func_info); > | > > Signed-off-by: Tom Stellard <tstellar@redhat.com> Hi, thanks for this! If you want to contribute this patch to bpftool, I'd recommend sending it to the kernel BPF mailing list [0], rather than the IETF BPF mailing list, and making sure to add the maintainers in copy [1]. [0] https://docs.kernel.org/bpf/bpf_devel_QA.html#q-to-which-mailing-list-do-i-need-to-submit-my-bpf-patches [1] From kernel repo: ./scripts/get_maintainer.pl tools/bpf/bpftool/ > --- > tools/bpf/bpftool/btf_dumper.c | 2 ++ > tools/bpf/bpftool/prog.c | 2 ++ > 2 files changed, 4 insertions(+) > > diff --git a/tools/bpf/bpftool/btf_dumper.c b/tools/bpf/bpftool/btf_dumper.c > index 4e896d8a2416..363d3e592ce2 100644 > --- a/tools/bpf/bpftool/btf_dumper.c > +++ b/tools/bpf/bpftool/btf_dumper.c > @@ -68,6 +68,8 @@ static int dump_prog_id_as_func_ptr(const struct btf_dumper *d, > memset(&info, 0, sizeof(info)); > info.nr_func_info = 1; > info.func_info_rec_size = finfo_rec_size; > + /* Silence -Wuninitialized-const-pointer warning in clang >= 21. */ > + memset(&finfo, 0, sizeof(finfo)); How about simply initialising the variable when we declare it, instead? struct bpf_func_info finfo = {}; This would avoid adding the memset() and comment in the middle of the function, and keep it slightly more readable? Same for prog.c. Best regards, Quentin
- [Bpf] [PATCH] bpftool: Fix -Wuninitialized-const-… Tom Stellard
- [Bpf] Re: [PATCH] bpftool: Fix -Wuninitialized-co… Quentin Monnet