Message ID | 20230519235618.4078456-1-pan2.li@intel.com |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp37975vqo; Fri, 19 May 2023 16:57:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4qup+5Vt9n6kFu9mHOL6c9tzaei5mypri7wQMzKEryqtTLTvsN/4RqcVHqhNETX5e3WTVE X-Received: by 2002:a17:907:9804:b0:969:df2e:d7d1 with SMTP id ji4-20020a170907980400b00969df2ed7d1mr3208220ejc.24.1684540639370; Fri, 19 May 2023 16:57:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684540639; cv=none; d=google.com; s=arc-20160816; b=H/MsohxJc6NJpdAelz3ZZ4EaVwb/sQY5CudxUTcGNqRyXVRfkiI/RZTmGheTrZugqX y+79Bs5y9eCa09B/Lk4K1Oy2Y6rXgbzHiKeosy4TNGwKN21nz1wCntddvNkzKGKHzdL7 9vr7yrmI4qD910G9D/Id3JAPQf5MX8QKj/eKRMGNzhVwRs6o8CND8igmfVaqqWovUPqH 56egX6YxlvLCOXH97nZWQQ2rr86nx/GZq63nm9T8hqdGQJ5qkDeo6TY4kRx5CqeuL/8a vxsYN6O3ucGw2d/UQ/UQ94wbDfPKWtmFMByHy7T5Co3dDQo4xEL4Zg3fFR7H9M2P07pV 3CVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=Z1QSUdYnG7Exp0hPLEbkSioX8/jt84jMEi/CMmGaYQo=; b=LxJpbJ62SvtDMxIJGeRG+5x0w/rEBFyFY6WiZrSCvTvgiL1XHt2C+V41ajO0dmOzSC NoRjGS6kT6NwPmrNGf5UAWhs+RZP++NgUXbFy4kDH2CbqlNcw2EMzzHlxr0BxWsvzRcO veAdUYS2WsRP5OhQeRKs/yv6ubBNpV19W0c/pXLjbGvN/HSuHfMfwydd5ILYJD3mzaVC bh3bkRMh+7xC+FN8G3R4xsa+xLFnvZF9rYUkoPMlSHjzIGaiPj3lZorzkWgBypTrJQzM YjfujUe9jrhehLzsx2TLuzOWba2xZQSzKfvt7d+zmeE+qbE5NgFM3tNfHATaUBO6Fg03 em9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=UBbAg8Ia; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id fq3-20020a1709069d8300b00961878bed4fsi288114ejc.137.2023.05.19.16.57.19 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 16:57:19 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=UBbAg8Ia; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 04E8A3858415 for <ouuuleilei@gmail.com>; Fri, 19 May 2023 23:57:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 04E8A3858415 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684540638; bh=Z1QSUdYnG7Exp0hPLEbkSioX8/jt84jMEi/CMmGaYQo=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=UBbAg8Ia7KIgy4EfAaZ+iouAuLfO/BB1sndAk8Cd6AWIu29RnKU2Pk07FAlA/P4wh Ee3ekxG/No035i9Z/fXvC6xPa92Rh2S+PK96sltTxVcQ1rk00pMYgOBByUkm/Rb7TT SJH6DCPI/+XTQHNayzv7Sk8gyzWzYTrbdDRFdIE0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by sourceware.org (Postfix) with ESMTPS id 9083B3858C41 for <gcc-patches@gcc.gnu.org>; Fri, 19 May 2023 23:56:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9083B3858C41 X-IronPort-AV: E=McAfee;i="6600,9927,10715"; a="332120729" X-IronPort-AV: E=Sophos;i="6.00,178,1681196400"; d="scan'208";a="332120729" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2023 16:56:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10715"; a="877018503" X-IronPort-AV: E=Sophos;i="6.00,178,1681196400"; d="scan'208";a="877018503" Received: from shvmail02.sh.intel.com ([10.239.244.9]) by orsmga005.jf.intel.com with ESMTP; 19 May 2023 16:56:21 -0700 Received: from pli-ubuntu.sh.intel.com (pli-ubuntu.sh.intel.com [10.239.159.47]) by shvmail02.sh.intel.com (Postfix) with ESMTP id 5007210080C1; Sat, 20 May 2023 07:56:20 +0800 (CST) To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, kito.cheng@sifive.com, pan2.li@intel.com, yanzhang.wang@intel.com, jeffreyalaw@gmail.com Subject: [PATCH] Mode-Switching: Fix local array maybe uninitialized warning Date: Sat, 20 May 2023 07:56:18 +0800 Message-Id: <20230519235618.4078456-1-pan2.li@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_NONE, TXREP, 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 server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Pan Li via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: pan2.li@intel.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766368885488429282?= X-GMAIL-MSGID: =?utf-8?q?1766368885488429282?= |
Series |
Mode-Switching: Fix local array maybe uninitialized warning
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Li, Pan2 via Gcc-patches
May 19, 2023, 11:56 p.m. UTC
From: Pan Li <pan2.li@intel.com> There are 2 local array in function optimize_mode_switching. It will be initialized conditionally at the beginning but then always consumed in another loop. It may trigger the warning maybe-uninitialized, and may result in build failure when enable werror, aka warning as error. This patch will initialize the local array to zero explictly when declaration. Signed-off-by: Pan Li <pan2.li@intel.com> gcc/ChangeLog: * mode-switching.cc (entity_map): Initialize the array to zero. (bb_info): Ditto. --- gcc/mode-switching.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On 5/19/23 17:56, pan2.li@intel.com wrote: > From: Pan Li <pan2.li@intel.com> > > There are 2 local array in function optimize_mode_switching. It will be > initialized conditionally at the beginning but then always consumed in > another loop. It may trigger the warning maybe-uninitialized, and may > result in build failure when enable werror, aka warning as error. > > This patch will initialize the local array to zero explictly when > declaration. > > Signed-off-by: Pan Li <pan2.li@intel.com> > > gcc/ChangeLog: > > * mode-switching.cc (entity_map): Initialize the array to zero. > (bb_info): Ditto. OK. jeff
Committed, thanks Jeff. Pan -----Original Message----- From: Jeff Law <jeffreyalaw@gmail.com> Sent: Saturday, May 20, 2023 12:24 PM To: Li, Pan2 <pan2.li@intel.com>; gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai; kito.cheng@sifive.com; Wang, Yanzhang <yanzhang.wang@intel.com> Subject: Re: [PATCH] Mode-Switching: Fix local array maybe uninitialized warning On 5/19/23 17:56, pan2.li@intel.com wrote: > From: Pan Li <pan2.li@intel.com> > > There are 2 local array in function optimize_mode_switching. It will > be initialized conditionally at the beginning but then always consumed > in another loop. It may trigger the warning maybe-uninitialized, and > may result in build failure when enable werror, aka warning as error. > > This patch will initialize the local array to zero explictly when > declaration. > > Signed-off-by: Pan Li <pan2.li@intel.com> > > gcc/ChangeLog: > > * mode-switching.cc (entity_map): Initialize the array to zero. > (bb_info): Ditto. OK. jeff
diff --git a/gcc/mode-switching.cc b/gcc/mode-switching.cc index 2d2818f5674..64ae2bc29c3 100644 --- a/gcc/mode-switching.cc +++ b/gcc/mode-switching.cc @@ -499,8 +499,8 @@ optimize_mode_switching (void) bool need_commit = false; static const int num_modes[] = NUM_MODES_FOR_MODE_SWITCHING; #define N_ENTITIES ARRAY_SIZE (num_modes) - int entity_map[N_ENTITIES]; - struct bb_info *bb_info[N_ENTITIES]; + int entity_map[N_ENTITIES] = {}; + struct bb_info *bb_info[N_ENTITIES] = {}; int i, j; int n_entities = 0; int max_num_modes = 0;