Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2120140rwb; Thu, 27 Jul 2023 02:17:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlGE1zzp304nM4PI61GXcL2tcNxAR3lOa6bv5JN0TXylx+YMMxgvtco8mdVwV61Djknz5B80 X-Received: by 2002:a05:6a00:845:b0:682:5a68:9846 with SMTP id q5-20020a056a00084500b006825a689846mr5815091pfk.16.1690449429165; Thu, 27 Jul 2023 02:17:09 -0700 (PDT) Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fd21-20020a056a002e9500b0068664d7f3f2si1143127pfb.88.2023.07.27.02.16.57; Thu, 27 Jul 2023 02:17:09 -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; arc=fail (signature failed); 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=fail (p=NONE sp=NONE dis=NONE) header.from=eng.windriver.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234217AbjG0Iny (ORCPT + 99 others); Thu, 27 Jul 2023 04:43:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234854AbjG0In2 (ORCPT ); Thu, 27 Jul 2023 04:43:28 -0400 Received: from mx0b-0064b401.pphosted.com (mx0b-0064b401.pphosted.com [205.220.178.238]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7CACD9B4; Thu, 27 Jul 2023 01:26:53 -0700 (PDT) Received: from pps.filterd (m0250812.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 36R5q4Ip006491; Thu, 27 Jul 2023 08:25:58 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3s0636cav0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 08:25:58 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AUAiz19+tq5m18SuqhRhsSR/mqKIUbPDwr00k0ytbXsLlUQY/eYL/Uu81Hr/6i6cARkw+JMxrJKlCobohtVLA6aRg5AiifOlaFongBZsLdO2VcW3Bi1RjXF0uFmZVAlyOu1//8lBMM83FeI6Il5yATTGB1TTlhP0ft0xqXYAgZmzshEYZu8oL0RMA4ewquprTQZ8BSrCbeumUa5ItpuhLKHcomjyy6XwvUoETW2fP7HaC7PyWD/rvx+qg38bK4gMuF5nIEc/XcWGlHpNDL3INtO9GHWSC9b59MytoUO012Sn+0OICogn1hlXQiGpXqtePl4BqcY95WY9qzFb68P/CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kP1P2aVTqNdCp71UT5wobcYp4mbVlbJ6l6pnDfwcIOQ=; b=VlYzQktbSXd/LGwd2eKD5wBNgLi79q3qyxheNhe96lowbjmRHlV5nlrkwkB1K9krAShG+T1t4LrrWKjtq4myO6ROI/1aDL9R7iDYCjB5bVXu4dIBQboKRHVsvyGi5NGVlFan24pCCwcUYibU6XkLhIxOoxChGbDgiZo+8Sq/973sffQR5g8KqNYcXIMrDPqbmkANDbLIZBvblqT7uCRhAngqLA1JkWFxBq6LS94ve3ITHskIDor8bus4ynLEWBk6xSA+I4svtjbDDNXL/wRXHz+1sywn20pTloBQ2sqNY8AfPGan0SszRDmT4VG+NM3/M7kygdYuUKFTxqaTc0rL3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=eng.windriver.com; dkim=pass header.d=eng.windriver.com; arc=none Received: from MW4PR11MB5824.namprd11.prod.outlook.com (2603:10b6:303:187::19) by DM4PR11MB5230.namprd11.prod.outlook.com (2603:10b6:5:39a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.29; Thu, 27 Jul 2023 08:25:54 +0000 Received: from MW4PR11MB5824.namprd11.prod.outlook.com ([fe80::c8f6:72a0:67fa:5032]) by MW4PR11MB5824.namprd11.prod.outlook.com ([fe80::c8f6:72a0:67fa:5032%7]) with mapi id 15.20.6609.032; Thu, 27 Jul 2023 08:25:54 +0000 From: Xiangyu Chen To: bpf@vger.kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH] libbpf: fix warnings "'pad_type' 'pad_bits' 'new_off' may be used uninitialized" Date: Thu, 27 Jul 2023 16:25:36 +0800 Message-Id: <20230727082536.1974154-1-xiangyu.chen@eng.windriver.com> X-Mailer: git-send-email 2.34.1 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-ClientProxiedBy: SI2PR01CA0025.apcprd01.prod.exchangelabs.com (2603:1096:4:192::10) To MW4PR11MB5824.namprd11.prod.outlook.com (2603:10b6:303:187::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR11MB5824:EE_|DM4PR11MB5230:EE_ X-MS-Office365-Filtering-Correlation-Id: 18436092-6c89-4884-3c49-08db8e7b186d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CP8y1zeLBe9+1ObsYytldcsfURA6l/qRoph8MxFilrwXKDu0StCiPgnQHMOZXOe9Qhyp49KLspIQA98zBr4FeSj+lm6RyDoTBCDQIQllIDPf8RewrzUIx4lm6p6NHgtWF3pNGk70bHiUan6i7XMUuOQYjXtNrShjLCkdMfXx4YSxHNaPW9xcq3nTEK4iOXBq6SZ346VsTE0hP7ITI6mrPDIXVD9cdx6Te2wrXabQNoSl3oqsLo0qXR0Jj7S8Y0P9TU6HJS+RlHbY3vbXTti00wDm59fXao/iysl0Hb/AOk4UJCeIDFPxenhmOdIrFwk6oTgRPQKQG0wmxyNbc2LRuG1nOHLGzxQPUeku7uhh6h9AbORIjcq8agjYtVU21/NEAJUknzg5T3HuJtbpYyoh0YXbe/r7mHU354zXdFlxOSS8+s7EuUhn25nNucTm+pDZlwEpmSPqZUBUVlOZb448JMORPnx2MsOGEKWWZeEKIyme9NSNg2j3uSy6N56pTQWZf17tKLmutIRaWVO4d8qIwgAW+irKVabGLmnvfbiO4urQnGf6FqqSi6DYl8/GfDQKIjI83VTkZ5jiFhWle9RS/aB+8OA1tfP+NqDpCgsvrdlhL9SzmgKclJMbqYi+pzf5 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR11MB5824.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(39850400004)(366004)(376002)(136003)(346002)(396003)(451199021)(2906002)(41300700001)(316002)(44832011)(5660300002)(8676002)(8936002)(478600001)(186003)(2616005)(52116002)(6486002)(6666004)(83170400001)(6512007)(26005)(6506007)(1076003)(450100002)(38350700002)(38100700002)(66946007)(66476007)(66556008)(4326008)(6916009)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?GWVWqqhk7qhEboSEva2W7BASdB919jftOJdhoZoZPtiiZS/g7ZrX38BnJ+uA?= =?us-ascii?Q?vXRZkcU85AS30d80kAv+w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-ascii?Q?Z4z/C/roqFqkpefnJwprZd6xIZHzcW2KWMEuEhWgPCGieX7C+x9k4gW/Q7fJ?= =?us-ascii?Q?FQDyPJyFwyxj9ifaV/zrW/CI2RdytNjaJOnTkokK/oWZ3XHcFhR4s09La8lR?= =?us-ascii?Q?YvrTOP0tScWPPwP8RVcUDTRN+F5/IqogOYgnSaxBeNZb2oL4PLOylpV+GkV5?= =?us-ascii?Q?14Qe+ftnysgivZiR/knSzC4CvUvrN8JF0EETZQariQQaNn9jEUqOBiwfqQHD?= =?us-ascii?Q?2Q/yEgc2lvVJPzKgKPGfU62rNhc/cA1aNKXr7axL7G8FA3ds8XEA6wTmInEH?= =?us-ascii?Q?vXXFR5vZyZlqEgV2Igt5iMeu7sI0pE7JDHk7AisCXDkFORqD8xFu1RUNNDfG?= =?us-ascii?Q?tzm8x7Dq3Gv2KJdY3JOIUDNLPDwCUkxRcYg1d3ujID74hcrsQFAVReMDPy3w?= =?us-ascii?Q?iZh1girnemEsYhgvIGQJ3RUoKSYZNl+rO48mMrcbRsxHZTia7VQRmgy9cx/y?= =?us-ascii?Q?fnuA3LgMQ1OZ8PtmCB5S0qto1Q3mINXCaRlTpL7ZqPW1yjmyymNNiK/of5NF?= =?us-ascii?Q?irjPfpI4FUpiSyIRediqm0/aVMCtsF5meA3US06ZzraRvAlKfcPU6Zip3AuX?= =?us-ascii?Q?sKexzgonZ3pCZ3jJ5HXKEBraslZ/oCFT4BETg0iJhgq7kZYbRq4XS6ax5GA1?= =?us-ascii?Q?6w=3D=3D?= X-OriginatorOrg: eng.windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18436092-6c89-4884-3c49-08db8e7b186d X-MS-Exchange-CrossTenant-AuthSource: MW4PR11MB5824.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2023 08:25:54.6455 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HbxhHihK53INeKku+MFKoCicTisnonlSEpMhNLWUptNo27m+091mvpk9cRKfwWtmTdm71P6KUAsghNnhy6r7eepxWo5e+SVPo7886qbRAXQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB5230 X-Proofpoint-GUID: SLN7q00wkMd_aEcb_NOBzAvGfUtPARJy X-Proofpoint-ORIG-GUID: SLN7q00wkMd_aEcb_NOBzAvGfUtPARJy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-26_08,2023-07-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 clxscore=1011 mlxscore=0 bulkscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2306200000 definitions=main-2307270074 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,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 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: | 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