DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Reshma Pattan <reshma.pattan@intel.com>
Subject: [PATCH 3/5] lib: use RTE_DIM
Date: Tue, 16 Apr 2024 08:19:29 -0700	[thread overview]
Message-ID: <20240416152124.69590-4-stephen@networkplumber.org> (raw)
In-Reply-To: <20240416152124.69590-1-stephen@networkplumber.org>

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>
---
 lib/cmdline/cmdline_vt100.c         | 4 +++-
 lib/latencystats/rte_latencystats.c | 3 +--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/cmdline/cmdline_vt100.c b/lib/cmdline/cmdline_vt100.c
index 4c9a46c953..61a2ecdd72 100644
--- a/lib/cmdline/cmdline_vt100.c
+++ b/lib/cmdline/cmdline_vt100.c
@@ -8,6 +8,8 @@
 #include <stdio.h>
 #include <string.h>
 
+#include <rte_common.h>
+
 #include "cmdline_vt100.h"
 
 const char *cmdline_vt100_commands[] = {
@@ -56,7 +58,7 @@ match_command(char *buf, unsigned int size)
 	size_t cmdlen;
 	unsigned int i = 0;
 
-	for (i=0 ; i<sizeof(cmdline_vt100_commands)/sizeof(const char *) ; i++) {
+	for (i = 0; i < RTE_DIM(cmdline_vt100_commands); i++) {
 		cmd = *(cmdline_vt100_commands + i);
 
 		cmdlen = strnlen(cmd, CMDLINE_VT100_BUF_SIZE);
diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c
index 4ea9b0d75b..7f8ee19846 100644
--- a/lib/latencystats/rte_latencystats.c
+++ b/lib/latencystats/rte_latencystats.c
@@ -75,8 +75,7 @@ static const struct latency_stats_nameoff lat_stats_strings[] = {
 	{"jitter_ns", offsetof(struct rte_latency_stats, jitter)},
 };
 
-#define NUM_LATENCY_STATS (sizeof(lat_stats_strings) / \
-				sizeof(lat_stats_strings[0]))
+#define NUM_LATENCY_STATS RTE_DIM(lat_stats_strings)
 
 int32_t
 rte_latencystats_update(void)
-- 
2.43.0


  parent reply	other threads:[~2024-04-16 15:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-16 15:19 [PATCH 0/5] use RTE_DIM where possible Stephen Hemminger
2024-04-16 15:19 ` [PATCH 1/5] cocci: add script to use RTE_DIM Stephen Hemminger
2024-04-16 15:19 ` [PATCH 2/5] app: " Stephen Hemminger
2024-04-16 15:30   ` Tyler Retzlaff
2024-04-17  6:13   ` [EXTERNAL] " Akhil Goyal
2024-04-16 15:19 ` Stephen Hemminger [this message]
2024-04-16 15:32   ` [PATCH 3/5] lib: " Tyler Retzlaff
2024-04-16 15:19 ` [PATCH 4/5] examples _use RTE_DIM Stephen Hemminger
2024-04-16 15:32   ` Tyler Retzlaff
2024-04-16 15:19 ` [PATCH 5/5] drivers/net: use RTE_DIM Stephen Hemminger
2024-04-16 16:29   ` Ferruh Yigit
2024-04-16 17:32     ` Stephen Hemminger
2024-04-17  8:00       ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240416152124.69590-4-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=reshma.pattan@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).