From f8b41a8e377153e11ebf8e67349708506e17a88f Mon Sep 17 00:00:00 2001 From: Conor Walsh Date: Wed, 11 Nov 2020 15:39:33 +0000 Subject: [PATCH] net/txgbe: fix build by simplifying xstats return When DPDK is compiled with gcc 7.5 with the optimization level set to 1 gcc sees the 'offset' variable in txgbe_ethdev.c as possibly being uninitialised. The 'txgbe_get_offset_by_id()' return value, "-(int)(id + 1)", seems confusing gcc that it assumes '0' can be returned in the failure case. To correct this the return statement for error case in 'txgbe_get_offset_by_id()' is simplified to return '-1'. Fixes: 91fe49c87d76 ("net/txgbe: support device xstats") Signed-off-by: Conor Walsh Reviewed-by: Ferruh Yigit --- drivers/net/txgbe/txgbe_ethdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index 9f533603a1..f8dffe1f12 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -2140,9 +2140,8 @@ txgbe_get_offset_by_id(uint32_t id, uint32_t *offset) nb * (TXGBE_NB_QP_STATS * sizeof(uint64_t)); return 0; } - id -= TXGBE_NB_QP_STATS * TXGBE_MAX_QP; - return -(int)(id + 1); + return -1; } static int txgbe_dev_xstats_get_names(struct rte_eth_dev *dev, -- 2.20.1