[PATCH 21.11] net/softnic: fix maybe-uninitialized warning

Kevin Traynor ktraynor at redhat.com
Wed Sep 11 16:12:59 CEST 2024


In pmd_mtr_stats_read() 'struct rte_mtr_stats s' is initialized
during the call to mtr_stats_convert() but on some systems it
is triggering a compiler warning. e.g.

drivers/net/softnic/rte_eth_softnic_meter.c:916:25: error: 's'
   may be used uninitialized [-Werror=maybe-uninitialized]

Initialize the struct in pmd_mtr_stats_read() to avoid warnings.

Reported-by: Ali Alnubani <alialnu at nvidia.com>
Signed-off-by: Kevin Traynor <ktraynor at redhat.com>
---
 drivers/net/softnic/rte_eth_softnic_meter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/softnic/rte_eth_softnic_meter.c b/drivers/net/softnic/rte_eth_softnic_meter.c
index 6b02f43e31..fea26f9c14 100644
--- a/drivers/net/softnic/rte_eth_softnic_meter.c
+++ b/drivers/net/softnic/rte_eth_softnic_meter.c
@@ -904,5 +904,5 @@ pmd_mtr_stats_read(struct rte_eth_dev *dev,
 	/* Stats format conversion. */
 	if (stats || stats_mask) {
-		struct rte_mtr_stats s;
+		struct rte_mtr_stats s = {0};
 		uint64_t s_mask = 0;
 
-- 
2.46.0



More information about the stable mailing list