[PATCH 4/5] examples _use RTE_DIM

Stephen Hemminger stephen at networkplumber.org
Tue Apr 16 17:19:30 CEST 2024


Use RTE_DIM instead of computing directly with sizeof.
Patch automatically generated via cocci/rte_dim.cocci.

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
 examples/l3fwd/main.c     | 3 +--
 examples/qos_sched/init.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index 8d32ae1dd5..3960d85202 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -116,8 +116,7 @@ static struct lcore_params lcore_params_array_default[] = {
 };
 
 static struct lcore_params * lcore_params = lcore_params_array_default;
-static uint16_t nb_lcore_params = sizeof(lcore_params_array_default) /
-				sizeof(lcore_params_array_default[0]);
+static uint16_t nb_lcore_params = RTE_DIM(lcore_params_array_default);
 
 static struct rte_eth_conf port_conf = {
 	.rxmode = {
diff --git a/examples/qos_sched/init.c b/examples/qos_sched/init.c
index d8abae635a..75629e36ea 100644
--- a/examples/qos_sched/init.c
+++ b/examples/qos_sched/init.c
@@ -206,8 +206,7 @@ struct rte_sched_subport_params subport_params[MAX_SCHED_SUBPORTS] = {
 		.n_pipes_per_subport_enabled = 4096,
 		.qsize = {64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64},
 		.pipe_profiles = pipe_profiles,
-		.n_pipe_profiles = sizeof(pipe_profiles) /
-			sizeof(struct rte_sched_pipe_params),
+		.n_pipe_profiles = RTE_DIM(pipe_profiles),
 		.n_max_pipe_profiles = MAX_SCHED_PIPE_PROFILES,
 		.cman_params = NULL,
 	},
-- 
2.43.0



More information about the dev mailing list