Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp944981rwb; Fri, 28 Jul 2023 02:12:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlEfmK/24A7Tfx1ff3QltwGrY1DtrpnhsDmZelFZWvxfk6tsimHM2W6yr2/g0cc3qi1qT2Y+ X-Received: by 2002:a17:906:779d:b0:99b:5085:42a2 with SMTP id s29-20020a170906779d00b0099b508542a2mr1902878ejm.40.1690535563206; Fri, 28 Jul 2023 02:12:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690535563; cv=none; d=google.com; s=arc-20160816; b=fqvpc6lyUbUOQfRDFkd0nOBDTheuD/26ouqJS9rG70VvDrlSaBIghX5lCYQe3IjbQ5 ss8qjJbp38MC80uVAgOUWzPBSiOGeCB7SIC0c/08PTSZba/mdDfRhlIaD1aFCeII+Lxe J98IuxxVHKbcE5leUl2qIYcxWhKkCOZlgrEI8hNmelhC0vhmF91x56w7IVZyXEfQjaKE YAryyDVkGmC6b7JE/I68cMEHDNB7SHhnazTwqxCG5RTRdBbuIO0Ur+StiZNswbemGeff uPbccR2cPYC3qIXv8NWGT1nzs0u1LP1kMVo+CUP8tdu37x2aeGXop70lGm068FnpwfiN eh5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:date:from:dkim-signature; bh=fSyIgkTDfn7ndWDwr/HaBWKVpiJ4+BDlR0fa7JayHA4=; fh=gNrFlgEJZTRSpw38g3k82KieYhRVfC9I5R0BtNJ8K+k=; b=SHEjH6PO30kpoyUe9XdYKOjnCzuwJ25dqC0KDw5FE6oA/JHzw4vqr8LsT54TO7s0Ph oNCYi0RF8OzmmlwZAtsccsV7qNC3TAGV5RYEVs4tpJJ1arCfqWXm7CJK+Shz0bxtBE3q irCKYDJIkVZxklwuSgo/JMDzqrCaOtBYnUpvazam2WB5sh3xSspVqtEeFWUZ6B/nKD3O FdgUrxlPxF0/GHIGrAs0Kb+UhM2nDod4TCp/D3qEjXss6zqsOAd5HySJfbOh2PJkXlzf DhUStXVqPIeHOiquBIX7PrSEIZIfN6GSTu6lLKi2SSXR57pnq0K/w8MknbKu7CMRQFMJ /aRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ZP+2bbfB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h12-20020a17090619cc00b00992e26642ddsi2361797ejd.251.2023.07.28.02.12.17; Fri, 28 Jul 2023 02:12:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ZP+2bbfB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234696AbjG1IKr (ORCPT + 99 others); Fri, 28 Jul 2023 04:10:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234636AbjG1IKa (ORCPT ); Fri, 28 Jul 2023 04:10:30 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF6EA3A8B; Fri, 28 Jul 2023 01:10:25 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-307d58b3efbso1753792f8f.0; Fri, 28 Jul 2023 01:10:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690531824; x=1691136624; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=fSyIgkTDfn7ndWDwr/HaBWKVpiJ4+BDlR0fa7JayHA4=; b=ZP+2bbfBzI+b3U33eXkS1KQ/jjCW2VYAjtcdGLsL1h9UGXdOUFnM+qAhmCCz0W8zEb e3UMgxsQrbXrY4H7aoWtFraYsOg7LjO/X6j3CCB3atPLFUYA+Ep01mb7+bADPeSexU0x fFZOleqO5jPA8MVE7qu3vIY88XX4YJabF6URwG4d3dNLkOCR4z8KfjN+w6yW1ATi4C5i zsYkaLyjW1C9TzppCXnv1YYxjo6zMKP3mBBqAtsNNdF1yvJYf9l95mXZ29JGFgQGdboN ilBjgzVksHPSfgTRVyrvmwDwS1w/03bLZQWfFJT2dDNNT4Gk2E+haDmM9QLYb7UjDLt+ PKEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690531824; x=1691136624; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fSyIgkTDfn7ndWDwr/HaBWKVpiJ4+BDlR0fa7JayHA4=; b=RLnzW8T7DJhZLPv4QbCtDFdljkji+C9YgzuQ+7FBKY/5yrMK15w4LiOGX/OSCBj3DD izFZZLLCYYINouVYa1SiEamaYkfDD4hT3Pd/pIBHDPakSnldxm4IJ55AzSAGUlJD3A0J KYWxAfysEi53Ce2aM+L6ibslfnXiE5F3+4b0pSsAhtJe3kQwB0OnjCDur/kMD/miLKrW K9qfvABkZh2mXFZSjnCFojYg7iIFyz1Bu50L4Nf+FE0fCTISY6mgHYUlfHQdMwHCxa++ 6hEccfXAJxuigsLjSYwyMqMGi3eFWXIHzXZQXzJG3K86iUMRs6ueCxxYo+4QAoUfXjeO JuAg== X-Gm-Message-State: ABy/qLawva2Efyy7fYdqUL0gje72C6QNY34UNJJ3d7f6obbQACMV0CWD n7KAsVfSJ+pMa8RVQfonY8jnavPZMHg= X-Received: by 2002:a5d:474c:0:b0:30f:b7b4:3e55 with SMTP id o12-20020a5d474c000000b0030fb7b43e55mr1109497wrs.19.1690531824123; Fri, 28 Jul 2023 01:10:24 -0700 (PDT) Received: from krava (2001-1ae9-1c2-4c00-726e-c10f-8833-ff22.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:726e:c10f:8833:ff22]) by smtp.gmail.com with ESMTPSA id l6-20020adfe586000000b0031416362e23sm4191734wrm.3.2023.07.28.01.10.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 01:10:23 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Fri, 28 Jul 2023 10:10:21 +0200 To: Yonghong Song Cc: Jiri Olsa , Xiangyu Chen , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] libbpf: fix warnings "'pad_type' 'pad_bits' 'new_off' may be used uninitialized" Message-ID: References: <20230727082536.1974154-1-xiangyu.chen@eng.windriver.com> <87f58a7c-2dee-9dcd-156f-edc41bfea38a@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87f58a7c-2dee-9dcd-156f-edc41bfea38a@linux.dev> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 27, 2023 at 11:23:21AM -0700, Yonghong Song wrote: > > > On 7/27/23 4:01 AM, Jiri Olsa wrote: > > On Thu, Jul 27, 2023 at 04:25:36PM +0800, Xiangyu Chen wrote: > > > From: Xiangyu Chen > > > > > > When turn on the yocto DEBUG_BUILD flag, the build options for gcc would enable maybe-uninitialized, > > > and following warnings would be reported as below: > > > > curious, what's the gcc version? I can't reproduce that, > > and we already have all warnings enabled: > > > > CFLAGS += -Werror -Wall > > > > they seem like false warnings also, because ARRAY_SIZE(pads) > > will be always > 0 > > Agree. This definitely a false positive. > In kernel top Makefile, we have > > # Enabled with W=2, disabled by default as noisy > ifdef CONFIG_CC_IS_GCC > KBUILD_CFLAGS += -Wno-maybe-uninitialized > endif > > That means gcc -maybe-uninitialized is very noisy. nice, I think we should do the same then ;-) bt not sure how to do the gcc check though jirka > > > > > jirka > > > > > > > > | btf_dump.c: In function 'btf_dump_emit_bit_padding': > > > | btf_dump.c:916:4: error: 'pad_type' may be used uninitialized in this function [-Werror=maybe-uninitialized] > > > | 916 | btf_dump_printf(d, "\n%s%s: %d;", pfx(lvl), pad_type, > > > | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > | 917 | in_bitfield ? new_off - cur_off : 0); > > > | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > | btf_dump.c:929:6: error: 'pad_bits' may be used uninitialized in this function [-Werror=maybe-uninitialized] > > > | 929 | if (bits == pad_bits) { > > > | | ^ > > > | btf_dump.c:913:28: error: 'new_off' may be used uninitialized in this function [-Werror=maybe-uninitialized] > > > | 913 | (new_off == next_off && roundup(cur_off, next_align * 8) != new_off) || > > > | | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > | HOSTLD scripts/mod/modpost > > > > > > Signed-off-by: Xiangyu Chen > > > --- > > > tools/lib/bpf/btf_dump.c | 4 ++-- > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c > > > index 4d9f30bf7f01..79923c3b8777 100644 > > > --- a/tools/lib/bpf/btf_dump.c > > > +++ b/tools/lib/bpf/btf_dump.c > > > @@ -867,8 +867,8 @@ static void btf_dump_emit_bit_padding(const struct btf_dump *d, > > > } pads[] = { > > > {"long", d->ptr_sz * 8}, {"int", 32}, {"short", 16}, {"char", 8} > > > }; > > > - int new_off, pad_bits, bits, i; > > > - const char *pad_type; > > > + int new_off = 0, pad_bits = 0, bits, i; > > > + const char *pad_type = NULL; > > > if (cur_off >= next_off) > > > return; /* no gap */ > > > -- > > > 2.34.1 > > > > > > > >