net/thunderx: fix build with gcc optimization on

build error gcc version 6.3.1 20161221 (Red Hat 6.3.1-1),
with EXTRA_CFLAGS="-O3":

.../drivers/net/thunderx/nicvf_ethdev.c:907:9:
   error: ‘txq’ may be used uninitialized in this function
   [-Werror=maybe-uninitialized]
  if (txq->pool_free == nicvf_single_pool_free_xmited_buffers)
      ~~~^~~~~~~~~~~
.../drivers/net/thunderx/nicvf_ethdev.c:886:20:
   note: ‘txq’ was declared here
  struct nicvf_txq *txq;
                    ^~~

Same error on function 'nicvf_eth_dev_init' and 'nicvf_dev_start', it
seems 'nicvf_set_tx_function' inlined when optimization enabled.

Initialize the txq and add NULL check before using it to fix.

Fixes: 7413feee66 ("net/thunderx: add device start/stop and close")
Cc: stable@dpdk.org

Reported-by: Richard Walsh <richard.walsh@intel.com>
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
This commit is contained in:
Ferruh Yigit 2018-06-21 19:14:50 +01:00
parent 9d453d1d8b
commit d90141961b

View File

@ -885,7 +885,7 @@ nicvf_dev_tx_queue_release(void *sq)
static void
nicvf_set_tx_function(struct rte_eth_dev *dev)
{
struct nicvf_txq *txq;
struct nicvf_txq *txq = NULL;
size_t i;
bool multiseg = false;
@ -906,6 +906,9 @@ nicvf_set_tx_function(struct rte_eth_dev *dev)
dev->tx_pkt_burst = nicvf_xmit_pkts;
}
if (!txq)
return;
if (txq->pool_free == nicvf_single_pool_free_xmited_buffers)
PMD_DRV_LOG(DEBUG, "Using single-mempool tx free method");
else