From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A8D5DA00C5; Thu, 7 May 2020 14:03:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3FB791DC26; Thu, 7 May 2020 14:03:12 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 03F501DBD1 for ; Thu, 7 May 2020 14:03:07 +0200 (CEST) IronPort-SDR: U/naxBJCtrbm4gh6ql4dCNcfpbvIpAd1mEY2n65DT+KPE2j4knRnNAvUuVpfJkKTnTpX8QkAuJ vnmypBFNWIOw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2020 05:03:06 -0700 IronPort-SDR: F12+gjUr1+5SwPMtPL2Ow+Q7xdbECn1DWbidK2I1eFpgFe0JYqG1T2Iqy6GJhY5uLYwKC9OUBF dm+mUwg2i8Aw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,363,1583222400"; d="scan'208";a="462122498" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.180]) by fmsmga006.fm.intel.com with ESMTP; 07 May 2020 05:03:02 -0700 From: Ferruh Yigit To: Honnappa Nagarahalli , Konstantin Ananyev Cc: dev@dpdk.org, Ferruh Yigit , Thomas Monjalon , David Marchand Date: Thu, 7 May 2020 13:02:57 +0100 Message-Id: <20200507120259.2197813-1-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 1/3] ring: fix build for gcc O1 optimization X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2) Two build errors: 1) In file included from .../build/include/rte_ring_elem.h:1093, from .../lib/librte_rcu/rte_rcu_qsbr.c:21: ../lib/librte_rcu/rte_rcu_qsbr.c: In function ‘rte_rcu_qsbr_dq_reclaim’: .../build/include/rte_ring_peek.h:282:22: error: ‘avail’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 282 | *available = avail - n; | ~~~~~~^~~ ./build/include/rte_ring_peek.h:259:11: note: ‘avail’ was declared here 259 | uint32_t avail, head, next; | ^~~~~ 2) In file included from .../build/include/rte_ring_elem.h:1093, from .../build/include/rte_ring.h:405, from .../app/test/test_ring_stress.h:13, from .../app/test/test_ring_stress_impl.h:5, from .../app/test/test_ring_peek_stress.c:5: .../app/test/test_ring_peek_stress.c: In function ‘_st_ring_enqueue_bulk’: .../build/include/rte_ring_peek.h:80:22: error: ‘free’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 80 | *free_space = free - n; | ~~~~~^~~ .../build/include/rte_ring_peek.h:60:11: note: ‘free’ was declared here 60 | uint32_t free, head, next; | ^~~~ The cases shouldn't be hit, and it looks like there is already logic error if it has been hit, but assigning 'avail' & 'free' to '0' to fix the build error. Signed-off-by: Ferruh Yigit --- lib/librte_ring/rte_ring_peek.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/librte_ring/rte_ring_peek.h b/lib/librte_ring/rte_ring_peek.h index d5e6ea1cf3..45f707dc7e 100644 --- a/lib/librte_ring/rte_ring_peek.h +++ b/lib/librte_ring/rte_ring_peek.h @@ -74,6 +74,7 @@ __rte_ring_do_enqueue_start(struct rte_ring *r, uint32_t n, /* unsupported mode, shouldn't be here */ RTE_ASSERT(0); n = 0; + free = 0; } if (free_space != NULL) @@ -273,6 +274,7 @@ __rte_ring_do_dequeue_start(struct rte_ring *r, void *obj_table, /* unsupported mode, shouldn't be here */ RTE_ASSERT(0); n = 0; + avail = 0; } if (n != 0) -- 2.25.4