From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id A3D6B1BE8E for ; Wed, 4 Jul 2018 05:10:56 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jul 2018 20:10:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,306,1526367600"; d="scan'208";a="69462644" Received: from dpdk-test32.sh.intel.com ([10.67.119.193]) by fmsmga001.fm.intel.com with ESMTP; 03 Jul 2018 20:10:54 -0700 From: Marvin Liu To: maxime.coquelin@redhat.com, ferruh.yigit@intel.com Cc: dev@dpdk.org, tiwei.bie@intel.com, Marvin Liu Date: Wed, 4 Jul 2018 18:56:25 +0800 Message-Id: <20180704105625.39462-1-yong.liu@intel.com> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] net/virtio: fix build with gcc optimization on 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: , X-List-Received-Date: Wed, 04 Jul 2018 03:10:58 -0000 build error on gcc version 8.1.1 20180502 (Red Hat 8.1.1-1), with optimization level >= O2 .../drivers/net/virtio/virtio_rxtx.c: In function ‘virtio_xmit_cleanup_inorder’: .../drivers/net/virtio/virtio_rxtx.c:195:24: error: ‘desc_idx’ may be used uninitialized in this function [-Werror=maybe-uninitialized] uint16_t i, used_idx, desc_idx, last_idx; ^~~~~~~~ Optimization option fcode-hoisting will cause error on gcc 8.x.x. Initialize desc_idx before using can fix build error. Fixes: e3851816e63c ("net/virtio: support in-order Rx and Tx") Reported-by: Ferruh Yigit Signed-off-by: Marvin Liu diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 6394071b8..19beb4bf4 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -192,7 +192,8 @@ virtio_xmit_cleanup(struct virtqueue *vq, uint16_t num) static void virtio_xmit_cleanup_inorder(struct virtqueue *vq, uint16_t num) { - uint16_t i, used_idx, desc_idx, last_idx; + uint16_t i, used_idx, last_idx; + uint16_t desc_idx = 0; int16_t free_cnt = 0; struct vq_desc_extra *dxp = NULL; -- 2.17.0