Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp273258rwb; Thu, 27 Jul 2023 12:30:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlFV12x6wWPj+a679UtfGgFiMDcZRuMmEXA2BVk5G1VkJDZZH8eWa4/wHBDqMUPqwyUqYQsn X-Received: by 2002:a17:906:2cd:b0:99b:c845:791d with SMTP id 13-20020a17090602cd00b0099bc845791dmr121086ejk.76.1690486205398; Thu, 27 Jul 2023 12:30:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690486205; cv=none; d=google.com; s=arc-20160816; b=ooRog5dWpgDJXg9QHOX2YBWzmnmRlaDBdS1Y46KueRY2wSiHER0EPMqzq6vrN7FbGT GpZGU2R94F6CGav/1RkO7jChUB+rEIS7RUEfNVSqJvD3u+YUbtIh4ltfrKqaAwJHwrUM Dj2ZB8J1VG9znIcfKnbnaRcSlly+T8PGDN2CUOw2u4v9OsuN0DZpAj+0Zb4ENZ8NjNqq iklL2+QQ2VPCDixBA9H0zJMB5B5ftOmiIYaToYII3BCt+PMDIXnsD9dhSzqCwf1OkDPQ JBlYNAcWDizYH2GuKfIsi/tSgZ/rnAW/UmRBjX57miPWn7Q5LVU6fQAbfl83X+94dTAr Cwvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:reply-to:mime-version :date:dkim-signature:message-id; bh=b60kJCPabQJkT35gIDAP++RJPy/QBXfwHhrngXV1+Vc=; fh=gyGs3G0MBMTVnMpaSzJZnIgdCjX7+qpSrMpheTR+CC4=; b=aOFw4MYIiiChUuriGEt+pkSQXSAt3FF6kGRa0OijrEqZGPf1F0i+toab4hXJZzD6yX c06RwA3tC/iYM8SSB8gBOmFKy/zGBawhMFXjPlIA3BF0rUO3+Xl0VV8qP7tLwAnkZlug w+cuAnGvnl1mzm1vVURL4rWtPf7jmBCSNDza8apYWc/RfkelWrbbQLi9VxfWYm9/bY1t /vpCtg/0NkK7ygu14Aib0FcJ2+3Z+B47XNAU3I3DhG1c/IXuqSCmgi5N4iVuT6mp+1B4 INsXMGQ1MsF2l55Xxci7GoBR41QieLQoYmaFonjJ9kWCJHw134yxOVEbhn1GuS0hC7/e RZcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=GBhnp40h; 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=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d9-20020a170906040900b0096f81ae0ac9si1400687eja.34.2023.07.27.12.29.38; Thu, 27 Jul 2023 12:30:05 -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=@linux.dev header.s=key1 header.b=GBhnp40h; 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=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230009AbjG0Sck (ORCPT + 99 others); Thu, 27 Jul 2023 14:32:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbjG0Sci (ORCPT ); Thu, 27 Jul 2023 14:32:38 -0400 X-Greylist: delayed 545 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 27 Jul 2023 11:32:33 PDT Received: from out-64.mta0.migadu.com (out-64.mta0.migadu.com [91.218.175.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83D9130ED for ; Thu, 27 Jul 2023 11:32:33 -0700 (PDT) Message-ID: <87f58a7c-2dee-9dcd-156f-edc41bfea38a@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1690482204; h=from:from:reply-to: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=b60kJCPabQJkT35gIDAP++RJPy/QBXfwHhrngXV1+Vc=; b=GBhnp40h4N+JLjjgkG9rLrjy4DKQ8eDs0BN68hfpHZaFaR+Poz24P0kYDbLohuxNntmJNJ E8V24Gz7GyY1dlGCsmeZN3qlwJIh+3PeNy2yarxDcxpeMoOpIWrDRZa2QRDf3VXkY5V/AN +boFxJEgSkofonb0zzFEv9qyws+IfcU= Date: Thu, 27 Jul 2023 11:23:21 -0700 MIME-Version: 1.0 Reply-To: yonghong.song@linux.dev Subject: Re: [PATCH] libbpf: fix warnings "'pad_type' 'pad_bits' 'new_off' may be used uninitialized" Content-Language: en-US To: Jiri Olsa , Xiangyu Chen Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230727082536.1974154-1-xiangyu.chen@eng.windriver.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yonghong Song In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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. > > 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 >> >> >