Skip to contentSkip to conversation

examples/vmdq_dcb: initialize all configuration structures

PATCH Applied Stephen Hemminger 3 participants 3 messages Feb 19 – Mar 17

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 examples/vmdq_dcb: initialize all configuration structures

Replace field-by-field assignment of local configuration structures with designated initializers. This ensures all fields, including enable_loop_back and any padding, are zero-initialized.

The Coverity warning was always latent; the earlier use of rte_memcpy() was hiding it from the analyzer.

Coverity issue: 501603

Fixes 8cc72f2814dd ("examples/vmdq_dcb: support X710")
---
 examples/vmdq_dcb/main.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)
examples/vmdq_dcb/main.c +15 -16
index 6eccee086d..d6f7b632b9 100644
@@ -132,23 +132,23 @@ static struct rte_ether_addr vmdq_ports_eth_addr[RTE_MAX_ETHPORTS];
 static inline int
 get_eth_conf(struct rte_eth_conf *eth_conf)
 {
-	struct rte_eth_vmdq_dcb_conf conf;
-	struct rte_eth_vmdq_rx_conf  vmdq_conf;
-	struct rte_eth_dcb_rx_conf   dcb_conf;
-	struct rte_eth_vmdq_dcb_tx_conf tx_conf;
+	struct rte_eth_vmdq_dcb_conf conf = {
+		.nb_queue_pools = (enum rte_eth_nb_pools)num_pools,
+		.nb_pool_maps = num_pools,
+	};
+	struct rte_eth_vmdq_rx_conf vmdq_conf = {
+		.nb_queue_pools = (enum rte_eth_nb_pools)num_pools,
+		.nb_pool_maps = num_pools,
+	};
+	struct rte_eth_dcb_rx_conf dcb_conf = {
+		.nb_tcs = (enum rte_eth_nb_tcs)num_tcs,
+	};
+	struct rte_eth_vmdq_dcb_tx_conf tx_conf = {
+		.nb_queue_pools = (enum rte_eth_nb_pools)num_pools,
+	};
 	uint8_t i;
 
-	conf.nb_queue_pools = (enum rte_eth_nb_pools)num_pools;
-	vmdq_conf.nb_queue_pools = (enum rte_eth_nb_pools)num_pools;
-	tx_conf.nb_queue_pools = (enum rte_eth_nb_pools)num_pools;
-	conf.nb_pool_maps = num_pools;
-	vmdq_conf.nb_pool_maps = num_pools;
-	conf.enable_default_pool = 0;
-	vmdq_conf.enable_default_pool = 0;
-	conf.default_pool = 0; /* set explicit value, even if not used */
-	vmdq_conf.default_pool = 0;
-
-	for (i = 0; i < conf.nb_pool_maps; i++) {
+	for (i = 0; i < num_pools; i++) {
 		conf.pool_map[i].vlan_id = vlan_tags[i];
 		vmdq_conf.pool_map[i].vlan_id = vlan_tags[i];
 		conf.pool_map[i].pools = 1UL << i;
@@ -159,7 +159,6 @@ get_eth_conf(struct rte_eth_conf *eth_conf)
 		dcb_conf.dcb_tc[i] = i % num_tcs;
 		tx_conf.dcb_tc[i] = i % num_tcs;
 	}
-	dcb_conf.nb_tcs = (enum rte_eth_nb_tcs)num_tcs;
 
 	*eth_conf = vmdq_dcb_conf_default;
 	eth_conf->rx_adv_conf.vmdq_dcb_conf = conf;
Signature · 1 line
2.51.0
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Stephen Hemminger

Replace field-by-field assignment of local configuration structures with designated initializers. This ensures all fields, including enable_loop_back and any padding, are zero-initialized.

The Coverity warning was always latent; the earlier use of rte_memcpy() was hiding it from the analyzer.

Quoted 9 lines

Coverity issue: 501603

Fixes 8cc72f2814dd ("examples/vmdq_dcb: support X710")
---
 examples/vmdq_dcb/main.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)
#2 lore raw

19/02/2026 09:59, Bruce Richardson:

Quoted 12 lines · Stephen Hemminger
Quoted 11 lines

Replace field-by-field assignment of local configuration structures with designated initializers. This ensures all fields, including enable_loop_back and any padding, are zero-initialized.

The Coverity warning was always latent; the earlier use of rte_memcpy() was hiding it from the analyzer.

Coverity issue: 501603

Fixes 8cc72f2814dd ("examples/vmdq_dcb: support X710")
Quoted 6 lines
Quoted 5 lines
---
 examples/vmdq_dcb/main.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

Applied, thanks.