From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9C408569B for ; Thu, 15 Dec 2022 18:13:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 099C9C433EF; Thu, 15 Dec 2022 18:13:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1671127998; bh=yAcrlxapSA193BaI+p6HvnTi2F1LTYMxaNUhWgnfKlY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VzQ3q/W1K/mrOTbugA5m/2IHc4BOPnCXjgrZHymlIEBzytuZQbtaeNUS4ijfge96p 04AugqL4AaFpP5/+cb7m6JRBi5eJwLKpzCwVDPf17EHb+buh3FyH8YVFWyp3julwGf WCv94/FNd8R6ynimAkPJS7cl1d4ovSo1Ivi4T1Hc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Michael , Daniel Borkmann , Stanislav Fomichev , Alan Maguire Subject: [PATCH 6.0 04/16] libbpf: Fix uninitialized warning in btf_dump_dump_type_data Date: Thu, 15 Dec 2022 19:10:48 +0100 Message-Id: <20221215172908.338365689@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221215172908.162858817@linuxfoundation.org> References: <20221215172908.162858817@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: David Michael commit dfd0afbf151d85411b371e841f62b81ee5d1ca54 upstream. GCC 11.3.0 fails to compile btf_dump.c due to the following error, which seems to originate in btf_dump_struct_data where the returned value would be uninitialized if btf_vlen returns zero. btf_dump.c: In function ‘btf_dump_dump_type_data’: btf_dump.c:2363:12: error: ‘err’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 2363 | if (err < 0) | ^ Fixes: 920d16af9b42 ("libbpf: BTF dumper support for typed data") Signed-off-by: David Michael Signed-off-by: Daniel Borkmann Acked-by: Stanislav Fomichev Acked-by: Alan Maguire Link: https://lore.kernel.org/bpf/87zgcu60hq.fsf@gmail.com Signed-off-by: Greg Kroah-Hartman --- tools/lib/bpf/btf_dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/tools/lib/bpf/btf_dump.c +++ b/tools/lib/bpf/btf_dump.c @@ -1963,7 +1963,7 @@ static int btf_dump_struct_data(struct b { const struct btf_member *m = btf_members(t); __u16 n = btf_vlen(t); - int i, err; + int i, err = 0; /* note that we increment depth before calling btf_dump_print() below; * this is intentional. btf_dump_data_newline() will not print a