Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2276113rwb; Thu, 27 Jul 2023 05:05:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlGtW/+oJnVOq1zH5xmntOBBqQrfZ7qPhsxwyAlGlofr/IY/wv1EhpHl2QFrchR2x7kujo++ X-Received: by 2002:a05:6a00:3a2a:b0:66e:4df5:6c10 with SMTP id fj42-20020a056a003a2a00b0066e4df56c10mr5275238pfb.34.1690459549755; Thu, 27 Jul 2023 05:05:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690459549; cv=none; d=google.com; s=arc-20160816; b=coP7koa5eknsQhdIWBIXEFXQyiySLb5moPx0gQJuBuktND/gmgjZfvrpwdqTt0u8sX kci3FJIhVsmy6BByhQAX/ZIhY/DMZVGAh1zUB5n8F0QuvBLLpFZDsTm3mTb11/UWLZIY nJ9hW6uOprFbaZnXK/O/CgO8IeopbJBcNm9GpJo+dtY9tINpWgjCwoZQPst3ym/kFDX3 YMCOX51XyqmqEwBLsn2AmifsHTodSP5Y4q4f2t8He7g5y7s2/XtyG+Gh604KzsDOUjuW /dwZ3VcuBGpClQf5sa45p4VeGFp3EACJNeOzjXUQQbYhPipQbi3GEzT8tC0ZHPlF2SmU s5jg== 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=YHfvgh8rSSrdkQk5e+JkE++Yn7WaF+CVtRWpok9XC9Y=; fh=in2Ns1qo7eeED3QF5D9K5QzZ76EArH5rwIUOTPnnkFg=; b=LcCPp9PEewzJD0opxRG/yD45P0ArqDyQ94D+rhB54cjLLr7HkqxsDa460EyJXNsSnd ZnL3qJWkTWiu8SF3KVcq0PdLakq42h5tAGma1/kLKisk4etIyJD51r0lTwvuCbv/CsL1 cZl+9eNfdBFDQbwIuDJlavrBfKVo+YscKdPq5DjTzIk1+ppP0bN40of06Zh/Buj7U2OB ZYc43nILb2/oaYi7APhC7ywwkvhEcsxmfJk3XpfGwjekpqtnjbhB5bpBlJzPFDeYcOd7 mWWgwsUsMMLBPVJ5JceKoYG+s7rxXNqMEfWAXFUdun1wGptGbS7YHf4gr4Aahlhxh7Rm QmbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=bRqxGL26; 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 b16-20020a056a000cd000b006828af9aeb5si1300342pfv.352.2023.07.27.05.05.35; Thu, 27 Jul 2023 05:05:49 -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=bRqxGL26; 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 S231569AbjG0LBu (ORCPT + 99 others); Thu, 27 Jul 2023 07:01:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230466AbjG0LBt (ORCPT ); Thu, 27 Jul 2023 07:01:49 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B8B11FEC; Thu, 27 Jul 2023 04:01:48 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-99bdeae1d0aso38725566b.1; Thu, 27 Jul 2023 04:01:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690455706; x=1691060506; 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=YHfvgh8rSSrdkQk5e+JkE++Yn7WaF+CVtRWpok9XC9Y=; b=bRqxGL26+Cd4UDJMsCRgvHHMbT81l6+oh+WQ2BqDYUGtTo2K3iTnsbNqccRgY/Byz/ vPTwqRRFSrPzJpytHiM28SzqGji9BPWO15KZPEvup3CQnvFvmTFzESAYuHycDgwKiPCa MuoOQdSAgoLgmr2wkrqPECTLGd8mdI9SeZj5LBE14vMx2qYPhrwXbcO5UuyWNGtiOIck jky8AGRxvfIKKr+qHyZ/JqPG/hpATQmDozL0O6tSm37W5PUT3XnjWVSwTUEOyFc6lK/b rQUV+kox2Rs5IBQ/Ic1X9hohq1x4QWvZtt7SGI4bbL4TXB0mQsE39lHid+Bg8EsQFvDc 4wsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690455706; x=1691060506; 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=YHfvgh8rSSrdkQk5e+JkE++Yn7WaF+CVtRWpok9XC9Y=; b=Ai37Gn0oqMZSQFFHmyvY76jf+oXyHPAFRnorri+ylwa30ZRjlYnEK0rIfDK9F3E4lj acpEMEOsqYTnLS4v2jcgEJCShioS+Kk/hKcR1UDrXr0kXkXUfsR9nhZO92E8jqFgrdSf /0JUZIo1BfE8wgerFzcAEj0c2QWHg8mVS1RSz73uSNAfqtbzvQrnqrVC+UM01ufIYMzj n6085oedJ6vRwSV3pMG8lW4Oi+jAoHtMY77xrM40ZAYh3iWc8UFCQdjQkeHlY6QA4Bze C0V/Zw927PhJLzHlrjvLVxNRRNGF83IfmeyPjEGGg98NcTZuSzwozohHl4vq41Esjh77 QwBw== X-Gm-Message-State: ABy/qLbKZfFQdKrpLNU8e5rh2XI21xGfK4zG+WSn6tS1H72wLmwxnH4g W7ctKxiZmOhlHWBPPbTerKtTmNH5JcY= X-Received: by 2002:a17:906:10cd:b0:99b:d243:157c with SMTP id v13-20020a17090610cd00b0099bd243157cmr1845316ejv.31.1690455706292; Thu, 27 Jul 2023 04:01:46 -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 t26-20020a1709064f1a00b0099bd86f9248sm631649eju.63.2023.07.27.04.01.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 04:01:45 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Thu, 27 Jul 2023 13:01:43 +0200 To: Xiangyu Chen Cc: 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230727082536.1974154-1-xiangyu.chen@eng.windriver.com> 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 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 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 > >