net/txgbe: offset needs to be initialised to fix gcc compile error
PATCH 1/1 net/txgbe: offset needs to be initialised to fix gcc compile error
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. To correct this error offset has been initialised to 0 in txgbe_ethdev.c
--- drivers/net/txgbe/txgbe_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/txgbe/txgbe_ethdev.c +2 -2
@@ -2247,7 +2247,7 @@ txgbe_dev_xstats_get_(struct rte_eth_dev *dev, uint64_t *values,/* Extended stats from txgbe_hw_stats */ for (i =0 ; i < limit; i++) { -uint32_t offset; +uint32_t offset =0 ;if (txgbe_get_offset_by_id (i, &offset)) {PMD_INIT_LOG (WARNING ,"id value %d isn't valid" , i);
@@ -2270,7 +2270,7 @@ txgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,return txgbe_dev_xstats_get_ (dev, values, limit);for (i =0 ; i < limit; i++) { -uint32_t offset; +uint32_t offset =0 ;if (txgbe_get_offset_by_id (ids[i], &offset)) {PMD_INIT_LOG (WARNING ,"id value %d isn't valid" , i);
Signature · 1 line
2.25.1
Quoted 15 lines · Conor Walsh
When DPDK is compiled with gcc 7.5 with the optimization level set to 1 gcc sees the offset variable in
txgbe_ethdev.cas possibly being uninitialised. To correct this error offset has been initialised to 0 intxgbe_ethdev.cSigned-off-by Conor Walsh <[email protected]>--- drivers/net/txgbe/txgbe_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/txgbe/txgbe_ethdev.c +0
-0
drivers/net/txgbe/txgbe_ethdev.c txgbe_dev_xstats_get_(struct rte_eth_dev *dev, uint64_t *values, · line 2251
Quoted 6 lines
drivers/net/txgbe/txgbe_ethdev.c +1
-1@@ -2247,7 +2247,7 @@ txgbe_dev_xstats_get_(struct rte_eth_dev *dev, uint64_t *values,/* Extended stats from txgbe_hw_stats */ for (i =0 ; i < limit; i++) { -uint32_t offset; +uint32_t offset =0 ;
This is false positive, right?
Is there an actual case that 'offset' is used without initialization?
'txgbe_get_offset_by_id()' return value seems used only to detect fail/success,
can you please try with 'txgbe_get_offset_by_id()' returning a simple '-1' on failure, instead of current "-(int)(id + 1)", if it helps with the compiler warning?
PATCH v2 1/1 net/txgbe: return changed to fix gcc compile error
In reply to Conor WalshWhen 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. To correct this the final return statement in txgbe_get_offset_by_id was simplified to return -1.
--- drivers/net/txgbe/txgbe_ethdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/txgbe/txgbe_ethdev.c +1 -2
@@ -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,
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v2] net/txgbe: return changed to fix gcc compile error
Quoted 6 lines · Conor Walsh
When DPDK is compiled with gcc 7.5 with the optimization level set to 1 gcc sees the offset variable in
txgbe_ethdev.cas possibly being uninitialised. To correct this the final return statement intxgbe_get_offset_by_idwas simplified to return -1.Signed-off-by Conor Walsh <[email protected]>
Applied to dpdk-next-net/main, thanks.