[4/5] examples _use RTE_DIM

Message ID 20240416152124.69590-5-stephen@networkplumber.org (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series use RTE_DIM where possible |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger April 16, 2024, 3:19 p.m. UTC
  Use RTE_DIM instead of computing directly with sizeof.
Patch automatically generated via cocci/rte_dim.cocci.

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

Comments

Tyler Retzlaff April 16, 2024, 3:32 p.m. UTC | #1
On Tue, Apr 16, 2024 at 08:19:30AM -0700, Stephen Hemminger wrote:
> Use RTE_DIM instead of computing directly with sizeof.
> Patch automatically generated via cocci/rte_dim.cocci.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---

Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
  

Patch

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,
 	},