Checks
Commit Message
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(-)
Comments
On Tue, Apr 16, 2024 at 08:19:29AM -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>
@@ -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);
@@ -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)