[PATCH] examples/vmdq_dcb: initialize all configuration structures

Stephen Hemminger stephen at networkplumber.org
Thu Feb 19 01:33:54 CET 2026


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")
Cc: stable at dpdk.org

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
 examples/vmdq_dcb/main.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/examples/vmdq_dcb/main.c b/examples/vmdq_dcb/main.c
index 6eccee086d..d6f7b632b9 100644
--- a/examples/vmdq_dcb/main.c
+++ b/examples/vmdq_dcb/main.c
@@ -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;
-- 
2.51.0



More information about the stable mailing list