Skip to contentSkip to conversation

use RTE_DIM where possible

PATCH In review Stephen Hemminger 4 participants 13 messages Apr 16, 2024 – Apr 17, 2024 Network drivers

lore
Share & tools
lore
#0 lore raw

cover use RTE_DIM where possible

There is macro for computing the number of elements in an array RTE_DIM. But it is not used in many places where it could be.
Based on similar coccinelle script in Linux.

Stephen Hemminger (5):
cocci: add script to use RTE_DIM
app: use RTE_DIM
lib: use RTE_DIM
examples _use RTE_DIM
drivers/net: use RTE_DIM

 app/test-flow-perf/main.c              |  4 +--
 app/test/test_ethdev_link.c            |  3 +-
 app/test/test_security_inline_macsec.c | 47 +++++++++++++-------------
 devtools/cocci/rte-dim.cocci           | 23 +++++++++++++
 drivers/net/ark/ark_pktchkr.c          |  2 +-
 drivers/net/ark/ark_pktgen.c           |  2 +-
 drivers/net/bnxt/bnxt_hwrm.c           | 12 +++----
 drivers/net/e1000/em_rxtx.c            |  3 +-
 drivers/net/iavf/iavf_ipsec_crypto.c   |  3 +-
 drivers/net/igc/igc_ethdev.c           |  3 +-
 drivers/net/ipn3ke/ipn3ke_tm.c         |  3 +-
 drivers/net/ngbe/ngbe_ethdev.c         |  6 ++--
 drivers/net/octeontx/octeontx_stats.h  |  3 +-
 drivers/net/txgbe/txgbe_ethdev.c       |  9 ++---
 drivers/net/txgbe/txgbe_ethdev_vf.c    |  3 +-
 examples/l3fwd/main.c                  |  3 +-
 examples/qos_sched/init.c              |  3 +-
 lib/cmdline/cmdline_vt100.c            |  4 ++-
 lib/latencystats/rte_latencystats.c    |  3 +-
 19 files changed, 73 insertions(+), 66 deletions(-)
 create mode 100644 devtools/cocci/rte-dim.cocci
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/5 cocci: add script to use RTE_DIM

New script to find RTE_DIM should be used.

---
 devtools/cocci/rte-dim.cocci | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 devtools/cocci/rte-dim.cocci
devtools/cocci/rte-dim.cocci new file +23 -0
new file mode 100644
index 0000000000..e7fcadec98
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: BSD-3-Clause
+// Use RTE_DIM macro instead of dividing sizeof array with sizeof an elmemnt
+//
+// Based of Linux kernela array_size.cocci
+//
+@@
+type T;
+T[] E;
+@@
+(
+|
+- (sizeof(E)/sizeof(E[...]))
++ RTE_DIM(E)
+|
+- (sizeof(E)/sizeof(*E))
++ RTE_DIM(E)
+|
+- (sizeof(E)/sizeof(T))
++ RTE_DIM(E)
+|
+- RTE_DIM((E))
++ RTE_DIM(E)
+)
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/5 app: use RTE_DIM

In reply to Stephen Hemminger

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

---
 app/test-flow-perf/main.c              |  4 +--
 app/test/test_ethdev_link.c            |  3 +-
 app/test/test_security_inline_macsec.c | 47 +++++++++++++-------------
 3 files changed, 25 insertions(+), 29 deletions(-)
app/test-flow-perf/main.c +1 -3
index e224ef6798..e9ef1ae04c 100644
@@ -965,9 +965,7 @@ args_parse(int argc, char **argv)
 						"meter-profile") == 0) {
 				i = 0;
 				token = strsep(&optarg, ",\0");
-				while (token != NULL && i < sizeof(
-						meter_profile_values) /
-						sizeof(uint64_t)) {
+				while (token != NULL && i < RTE_DIM(meter_profile_values)) {
 					meter_profile_values[i++] = atol(token);
 					token = strsep(&optarg, ",\0");
 				}
app/test/test_ethdev_link.c +1 -2
index f063a5fe26..e305df71be 100644
@@ -135,8 +135,7 @@ test_link_speed_all_values(void)
 		{ "Invalid",   50505 }
 	};
 
-	for (i = 0; i < sizeof(speed_str_map) / sizeof(struct link_speed_t);
-			i++) {
+	for (i = 0; i < RTE_DIM(speed_str_map); i++) {
 		speed = rte_eth_link_speed_to_str(speed_str_map[i].link_speed);
 		TEST_ASSERT_BUFFERS_ARE_EQUAL(speed_str_map[i].value,
 			speed, strlen(speed_str_map[i].value),
app/test/test_security_inline_macsec.c +23 -24

185 lines not on this page · raw message

Signature · 1 line
2.43.0
Acked-by on v1 2/5
#4 lore raw

RE: [EXTERNAL] [PATCH 2/5] app: use RTE_DIM

In reply to Stephen Hemminger
Quoted 9 lines

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

---
 app/test-flow-perf/main.c              |  4 +--
 app/test/test_ethdev_link.c            |  3 +-
 app/test/test_security_inline_macsec.c | 47 +++++++++++++-------------
 3 files changed, 25 insertions(+), 29 deletions(-)
#5 lore raw

PATCH 3/5 lib: use RTE_DIM

In reply to Stephen Hemminger

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

---
 lib/cmdline/cmdline_vt100.c         | 4 +++-
 lib/latencystats/rte_latencystats.c | 3 +--
 2 files changed, 4 insertions(+), 3 deletions(-)
lib/cmdline/cmdline_vt100.c +3 -1
index 4c9a46c953..61a2ecdd72 100644
@@ -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);
lib/latencystats/rte_latencystats.c +1 -2
index 4ea9b0d75b..7f8ee19846 100644
@@ -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)
Signature · 1 line
2.43.0
#7 lore raw

PATCH 4/5 examples _use RTE_DIM

In reply to Stephen Hemminger

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

---
 examples/l3fwd/main.c     | 3 +--
 examples/qos_sched/init.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
examples/l3fwd/main.c +1 -2
index 8d32ae1dd5..3960d85202 100644
@@ -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 = {
examples/qos_sched/init.c +1 -2
index d8abae635a..75629e36ea 100644
@@ -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,
 	},
Signature · 1 line
2.43.0
#9 lore raw

PATCH 5/5 drivers/net: use RTE_DIM

In reply to Stephen Hemminger

Use RTE_DIM instead of computing directly with sizeof. Patch automatically generated via cocci/rte_dim.cocci. Code in base/ subdirectory manually excluded.

---
 drivers/net/ark/ark_pktchkr.c         |  2 +-
 drivers/net/ark/ark_pktgen.c          |  2 +-
 drivers/net/bnxt/bnxt_hwrm.c          | 12 ++++++------
 drivers/net/e1000/em_rxtx.c           |  3 +--
 drivers/net/iavf/iavf_ipsec_crypto.c  |  3 +--
 drivers/net/igc/igc_ethdev.c          |  3 +--
 drivers/net/ipn3ke/ipn3ke_tm.c        |  3 +--
 drivers/net/ngbe/ngbe_ethdev.c        |  6 ++----
 drivers/net/octeontx/octeontx_stats.h |  3 +--
 drivers/net/txgbe/txgbe_ethdev.c      |  9 +++------
 drivers/net/txgbe/txgbe_ethdev_vf.c   |  3 +--
 11 files changed, 19 insertions(+), 30 deletions(-)
drivers/net/ark/ark_pktchkr.c +1 -1
index e1f336c73c..63c298fca8 100644
@@ -320,7 +320,7 @@ options(const char *id)
 {
 	unsigned int i;
 
-	for (i = 0; i < sizeof(toptions) / sizeof(struct OPTIONS); i++) {
+	for (i = 0; i < RTE_DIM(toptions); i++) {
 		if (strcmp(id, toptions[i].opt) == 0)
 			return &toptions[i];
 	}
drivers/net/ark/ark_pktgen.c +1 -1
index 69ff7072b2..98e692c3ad 100644
@@ -297,7 +297,7 @@ options(const char *id)
 {
 	unsigned int i;
 
-	for (i = 0; i < sizeof(toptions) / sizeof(struct OPTIONS); i++) {
+	for (i = 0; i < RTE_DIM(toptions); i++) {
 		if (strcmp(id, toptions[i].opt) == 0)
 			return &toptions[i];
 	}
drivers/net/bnxt/bnxt_hwrm.c +6 -6
index 6ea7089a3f..68d7382806 100644
@@ -72,13 +72,13 @@ const char *media_type[] = { "Unknown", "Twisted Pair",
 	"Direct Attached Copper", "Fiber"
 };
 
-#define MAX_MEDIA_TYPE (sizeof(media_type) / sizeof(const char *))
+#define MAX_MEDIA_TYPE RTE_DIM(media_type)
 
 const char *link_status_str[] = { "Down. No link or cable detected.",
 	"Down. No link, but a cable has been detected.", "Up.",
 };
 
-#define MAX_LINK_STR (sizeof(link_status_str) / sizeof(const char *))
+#define MAX_LINK_STR RTE_DIM(link_status_str)
 
 const char *fec_mode[] = {
 	"No active FEC",
@@ -90,13 +90,13 @@ const char *fec_mode[] = {
 	"FEC RS(272,257)"
 };
 
-#define MAX_FEC_MODE (sizeof(fec_mode) / sizeof(const char *))
+#define MAX_FEC_MODE RTE_DIM(fec_mode)
 
 const char *signal_mode[] = {
 	"NRZ", "PAM4", "PAM4_112"
 };
 
-#define MAX_SIG_MODE (sizeof(signal_mode) / sizeof(const char *))
+#define MAX_SIG_MODE RTE_DIM(signal_mode)
 
 /* multi-purpose multi-key table container.
  * Add a unique entry for a new PHY attribs as per HW CAS.
@@ -226,7 +226,7 @@ struct link_speeds2_tbl {
 	},
 };
 
-#define BNXT_SPEEDS2_TBL_SZ (sizeof(link_speeds2_tbl) / sizeof(*link_speeds2_tbl))
+#define BNXT_SPEEDS2_TBL_SZ RTE_DIM(link_speeds2_tbl)
 
 /* In hwrm_phy_qcfg reports trained up speeds in link_speed(offset:0x8[31:16]) */
 struct link_speeds_tbl {
@@ -269,7 +269,7 @@ struct link_speeds_tbl {
 	},
 };
 
-#define BNXT_SPEEDS_TBL_SZ (sizeof(link_speeds_tbl) / sizeof(*link_speeds_tbl))
+#define BNXT_SPEEDS_TBL_SZ RTE_DIM(link_speeds_tbl)
 
 static const char *bnxt_get_xcvr_type(uint32_t xcvr_identifier_type_tx_lpi_timer)
 {
drivers/net/e1000/em_rxtx.c +1 -2
index df5fbb7823..59d7793787 100644
@@ -1666,8 +1666,7 @@ em_rctl_bsize(__rte_unused enum e1000_mac_type hwtyp, uint32_t *bufsz)
 	 * ***************************************************************
 	 */
 
-	for (i = 0; i != sizeof(bufsz_to_rctl) / sizeof(bufsz_to_rctl[0]);
-			i++) {
+	for (i = 0; i != RTE_DIM(bufsz_to_rctl); i++) {
 		if (rctl_bsize >= bufsz_to_rctl[i].bufsz) {
 			*bufsz = bufsz_to_rctl[i].bufsz;
 			return bufsz_to_rctl[i].rctl;
drivers/net/iavf/iavf_ipsec_crypto.c +1 -2
index 6fd45ff45f..d3ce666ef0 100644
@@ -1483,8 +1483,7 @@ iavf_ipsec_crypto_capabilities_get(void *device)
 	 * crypto capabilities, except for last element of the array which is
 	 * the null termination
 	 */
-	for (i = 0; i < ((sizeof(iavf_security_capabilities) /
-			sizeof(iavf_security_capabilities[0])) - 1); i++) {
+	for (i = 0; i < (RTE_DIM(iavf_security_capabilities) - 1); i++) {
 		iavf_security_capabilities[i].crypto_capabilities =
 			iavf_sctx->crypto_capabilities;
 	}
drivers/net/igc/igc_ethdev.c +1 -2
index 87d7f7caa0..28682c42ae 100644
@@ -188,8 +188,7 @@ static const struct rte_igc_xstats_name_off rte_igc_stats_strings[] = {
 		offsetof(struct igc_hw_stats, icrxdmtc)},
 };
 
-#define IGC_NB_XSTATS (sizeof(rte_igc_stats_strings) / \
-		sizeof(rte_igc_stats_strings[0]))
+#define IGC_NB_XSTATS RTE_DIM(rte_igc_stats_strings)
 
 static int eth_igc_configure(struct rte_eth_dev *dev);
 static int eth_igc_link_update(struct rte_eth_dev *dev, int wait_to_complete);
drivers/net/ipn3ke/ipn3ke_tm.c +1 -2
index 0260227900..54687ce637 100644
@@ -67,8 +67,7 @@ struct ipn3ke_tm_shaper_params_range_type ipn3ke_tm_shaper_params_rang[] = {
 	{512,    1023,    15,    32768,    67108864,    134086656},
 };
 
-#define IPN3KE_TM_SHAPER_RANGE_NUM (sizeof(ipn3ke_tm_shaper_params_rang) / \
-	sizeof(struct ipn3ke_tm_shaper_params_range_type))
+#define IPN3KE_TM_SHAPER_RANGE_NUM RTE_DIM(ipn3ke_tm_shaper_params_rang)
 
 #define IPN3KE_TM_SHAPER_COMMITTED_RATE_MAX \
 	(ipn3ke_tm_shaper_params_rang[IPN3KE_TM_SHAPER_RANGE_NUM - 1].high)
drivers/net/ngbe/ngbe_ethdev.c +2 -4
index 4cd07a0030..f10b9647fa 100644
@@ -238,8 +238,7 @@ static const struct rte_ngbe_xstats_name_off rte_ngbe_stats_strings[] = {
 	HW_XSTAT_NAME(rx_xoff_packets, "rx_flow_control_xoff_packets"),
 };
 
-#define NGBE_NB_HW_STATS (sizeof(rte_ngbe_stats_strings) / \
-			   sizeof(rte_ngbe_stats_strings[0]))
+#define NGBE_NB_HW_STATS RTE_DIM(rte_ngbe_stats_strings)
 
 /* Per-queue statistics */
 #define QP_XSTAT(m) {#m, offsetof(struct ngbe_hw_stats, qp[0].m)}
@@ -251,8 +250,7 @@ static const struct rte_ngbe_xstats_name_off rte_ngbe_qp_strings[] = {
 	QP_XSTAT(rx_qp_mc_packets),
 };
 
-#define NGBE_NB_QP_STATS (sizeof(rte_ngbe_qp_strings) / \
-			   sizeof(rte_ngbe_qp_strings[0]))
+#define NGBE_NB_QP_STATS RTE_DIM(rte_ngbe_qp_strings)
 
 static inline int32_t
 ngbe_pf_reset_hw(struct ngbe_hw *hw)
drivers/net/octeontx/octeontx_stats.h +1 -2
index 73ef5e93bb..746205bb85 100644
@@ -36,6 +36,5 @@ struct octeontx_xstats octeontx_bgx_xstats[] = {
 	BGX_XSTAT(tx_pause_packets),
 };
 
-#define NUM_BGX_XSTAT \
-	(sizeof(octeontx_bgx_xstats) / sizeof(struct octeontx_xstats))
+#define NUM_BGX_XSTAT RTE_DIM(octeontx_bgx_xstats)
 #endif /* __OCTEONTX_STATS_H__ */
drivers/net/txgbe/txgbe_ethdev.c +3 -6
index b75e8898e2..fbf261bd0b 100644
@@ -269,8 +269,7 @@ static const struct rte_txgbe_xstats_name_off rte_txgbe_stats_strings[] = {
 	HW_XSTAT_NAME(rx_xoff_packets, "rx_flow_control_xoff_packets"),
 };
 
-#define TXGBE_NB_HW_STATS (sizeof(rte_txgbe_stats_strings) / \
-			   sizeof(rte_txgbe_stats_strings[0]))
+#define TXGBE_NB_HW_STATS RTE_DIM(rte_txgbe_stats_strings)
 
 /* Per-priority statistics */
 #define UP_XSTAT(m) {#m, offsetof(struct txgbe_hw_stats, up[0].m)}
@@ -290,8 +289,7 @@ static const struct rte_txgbe_xstats_name_off rte_txgbe_up_strings[] = {
 	UP_XSTAT(tx_up_xon2off_packets),
 };
 
-#define TXGBE_NB_UP_STATS (sizeof(rte_txgbe_up_strings) / \
-			   sizeof(rte_txgbe_up_strings[0]))
+#define TXGBE_NB_UP_STATS RTE_DIM(rte_txgbe_up_strings)
 
 /* Per-queue statistics */
 #define QP_XSTAT(m) {#m, offsetof(struct txgbe_hw_stats, qp[0].m)}
@@ -303,8 +301,7 @@ static const struct rte_txgbe_xstats_name_off rte_txgbe_qp_strings[] = {
 	QP_XSTAT(rx_qp_mc_packets),
 };
 
-#define TXGBE_NB_QP_STATS (sizeof(rte_txgbe_qp_strings) / \
-			   sizeof(rte_txgbe_qp_strings[0]))
+#define TXGBE_NB_QP_STATS RTE_DIM(rte_txgbe_qp_strings)
 
 static inline int
 txgbe_is_sfp(struct txgbe_hw *hw)
drivers/net/txgbe/txgbe_ethdev_vf.c +1 -2
index f1341fbf7e..be96519b97 100644
@@ -112,8 +112,7 @@ static const struct rte_txgbe_xstats_name_off rte_txgbevf_stats_strings[] = {
 			offsetof(struct txgbevf_hw_stats, qp[7].vfmprc)}
 };
 
-#define TXGBEVF_NB_XSTATS (sizeof(rte_txgbevf_stats_strings) /	\
-		sizeof(rte_txgbevf_stats_strings[0]))
+#define TXGBEVF_NB_XSTATS RTE_DIM(rte_txgbevf_stats_strings)
 
 /*
  * Negotiate mailbox API version with the PF.
Signature · 1 line
2.43.0
#10 lore raw

Re: [PATCH 5/5] drivers/net: use RTE_DIM

Quoted 6 lines · Stephen Hemminger

Use RTE_DIM instead of computing directly with sizeof. Patch automatically generated via cocci/rte_dim.cocci. Code in base/ subdirectory manually excluded.

Updated ones looks good to me, but I can see a few more, I don't know if you excluded base file one intentionally,
searched as git grep "sizeof.*\[0\]" drivers/net/

-
drivers/net/bnxt/tf_core/cfa_tcam_mgr.h:28:#define ARRAY_SIZE(_array) (sizeof(_array) / sizeof(_array[0]))

-
drivers/net/hinic/base/hinic_pmd_nicio.c:449: /
sizeof(hinic_hw_rx_buf_size[0]);

-
drivers/net/ice/ice_ethdev.c:330:#define ICE_NB_MBUF_XSTATS (sizeof(ice_mbuf_strings) / sizeof(ice_mbuf_strings[0]))

-
drivers/net/i40e/i40e_ethdev.c:554:#define I40E_NB_MBUF_XSTATS (sizeof(i40e_mbuf_strings) / sizeof(i40e_mbuf_strings[0]))

-
drivers/net/i40e/base/i40e_adminq.h:126: if (!((u32)aq_rc <
(sizeof(aq_to_posix) / sizeof((aq_to_posix)[0]))))

-
drivers/net/ipn3ke/ipn3ke_representor.c:506: /
sizeof(ipn3ke_rpst_hw_port_strings[0]))
drivers/net/ipn3ke/ipn3ke_representor.c:517: /
sizeof(ipn3ke_rpst_rxq_prio_strings[0]))
drivers/net/ipn3ke/ipn3ke_representor.c:530: /
sizeof(ipn3ke_rpst_txq_prio_strings[0]))

-
drivers/net/ixgbe/base/ixgbe_x550.c:443: for (i = 0; i <
sizeof(ixgbe_fw_map) / sizeof(ixgbe_fw_map[0]); ++i) {
drivers/net/ixgbe/base/ixgbe_x550.c:700: for (i = 0; i <
sizeof(ixgbe_fw_map) / sizeof(ixgbe_fw_map[0]); ++i) {

-
drivers/net/ixgbe/base/ixgbe_x550.c:3338: bufsz = sizeof(buf) /
sizeof(buf[0]);

-
drivers/net/mlx5/hws/mlx5dr_internal.h:52:#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))

#11 lore raw

Re: [PATCH 5/5] drivers/net: use RTE_DIM

Quoted 13 lines · On Tue, 16 Apr 2024 17:29:25 +0100 Ferruh Yigit <[email protected]> wrote:
Quoted 6 lines · Stephen Hemminger

Use RTE_DIM instead of computing directly with sizeof. Patch automatically generated via cocci/rte_dim.cocci. Code in base/ subdirectory manually excluded.

Updated ones looks good to me, but I can see a few more, I don't know if you excluded base file one intentionally,
searched as git grep "sizeof.*\[0\]" drivers/net/

Quoted 5 lines

-
drivers/net/bnxt/tf_core/cfa_tcam_mgr.h:28:#define ARRAY_SIZE(_array) (sizeof(_array) / sizeof(_array[0]))

-

For the drivers that choose to define and use ARRAY_SIZE() that is fine.

Since base/ directories often come from other upstream repos, I ignored those.

Something about the Intel drivers was causing warnings and the script would not automatically change those.

#12 lore raw

Re: [PATCH 5/5] drivers/net: use RTE_DIM

Quoted 16 lines · Stephen Hemminger
Quoted 13 lines · On Tue, 16 Apr 2024 17:29:25 +0100 Ferruh Yigit <[email protected]> wrote:
Quoted 6 lines · Stephen Hemminger

Use RTE_DIM instead of computing directly with sizeof. Patch automatically generated via cocci/rte_dim.cocci. Code in base/ subdirectory manually excluded.

Updated ones looks good to me, but I can see a few more, I don't know if you excluded base file one intentionally,
searched as git grep "sizeof.*\[0\]" drivers/net/

Quoted 8 lines
Quoted 5 lines

-
drivers/net/bnxt/tf_core/cfa_tcam_mgr.h:28:#define ARRAY_SIZE(_array) (sizeof(_array) / sizeof(_array[0]))

-

For the drivers that choose to define and use ARRAY_SIZE() that is fine.

ack
Although it can be updated as following, I don't think it differs #define ARRAY_SIZE(_array) RTE_DIM(_array)

Quoted 2 lines

Since base/ directories often come from other upstream repos, I ignored those.

ack

Quoted 3 lines

Something about the Intel drivers was causing warnings and the script would not automatically change those.

ICE_NB_MBUF_XSTATS, I40E_NB_MBUF_XSTATS & ipn3ke_representor.c ones seems can be updated, manually maybe?