[v1] net/txgbe: offset needs to be initialised to fix gcc compile error

Message ID 20201111130542.1949894-1-conor.walsh@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series [v1] net/txgbe: offset needs to be initialised to fix gcc compile error |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Conor Walsh Nov. 11, 2020, 1:05 p.m. UTC
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

Signed-off-by: Conor Walsh <conor.walsh@intel.com>
---
 drivers/net/txgbe/txgbe_ethdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Ferruh Yigit Nov. 11, 2020, 1:14 p.m. UTC | #1
On 11/11/2020 1:05 PM, Conor Walsh wrote:
> 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
> 
> Signed-off-by: Conor Walsh <conor.walsh@intel.com>
> ---
>   drivers/net/txgbe/txgbe_ethdev.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
> index 9f533603a1..7fd56c2698 100644
> --- a/drivers/net/txgbe/txgbe_ethdev.c
> +++ b/drivers/net/txgbe/txgbe_ethdev.c
> @@ -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

diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
index 9f533603a1..7fd56c2698 100644
--- a/drivers/net/txgbe/txgbe_ethdev.c
+++ b/drivers/net/txgbe/txgbe_ethdev.c
@@ -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);