diff --git a/drivers/net/ark/ark_pktchkr.c b/drivers/net/ark/ark_pktchkr.c
index e1f336c73c..63c298fca8 100644
--- a/drivers/net/ark/ark_pktchkr.c
+++ b/drivers/net/ark/ark_pktchkr.c
@@ -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];
 	}
diff --git a/drivers/net/ark/ark_pktgen.c b/drivers/net/ark/ark_pktgen.c
index 69ff7072b2..98e692c3ad 100644
--- a/drivers/net/ark/ark_pktgen.c
+++ b/drivers/net/ark/ark_pktgen.c
@@ -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];
 	}
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 6ea7089a3f..68d7382806 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -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)
 {
diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c
index df5fbb7823..59d7793787 100644
--- a/drivers/net/e1000/em_rxtx.c
+++ b/drivers/net/e1000/em_rxtx.c
@@ -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;
diff --git a/drivers/net/iavf/iavf_ipsec_crypto.c b/drivers/net/iavf/iavf_ipsec_crypto.c
index 6fd45ff45f..d3ce666ef0 100644
--- a/drivers/net/iavf/iavf_ipsec_crypto.c
+++ b/drivers/net/iavf/iavf_ipsec_crypto.c
@@ -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;
 	}
diff --git a/drivers/net/igc/igc_ethdev.c b/drivers/net/igc/igc_ethdev.c
index 87d7f7caa0..28682c42ae 100644
--- a/drivers/net/igc/igc_ethdev.c
+++ b/drivers/net/igc/igc_ethdev.c
@@ -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);
diff --git a/drivers/net/ipn3ke/ipn3ke_tm.c b/drivers/net/ipn3ke/ipn3ke_tm.c
index 0260227900..54687ce637 100644
--- a/drivers/net/ipn3ke/ipn3ke_tm.c
+++ b/drivers/net/ipn3ke/ipn3ke_tm.c
@@ -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)
diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c
index 4cd07a0030..f10b9647fa 100644
--- a/drivers/net/ngbe/ngbe_ethdev.c
+++ b/drivers/net/ngbe/ngbe_ethdev.c
@@ -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)
diff --git a/drivers/net/octeontx/octeontx_stats.h b/drivers/net/octeontx/octeontx_stats.h
index 73ef5e93bb..746205bb85 100644
--- a/drivers/net/octeontx/octeontx_stats.h
+++ b/drivers/net/octeontx/octeontx_stats.h
@@ -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__ */
diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
index b75e8898e2..fbf261bd0b 100644
--- a/drivers/net/txgbe/txgbe_ethdev.c
+++ b/drivers/net/txgbe/txgbe_ethdev.c
@@ -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)
diff --git a/drivers/net/txgbe/txgbe_ethdev_vf.c b/drivers/net/txgbe/txgbe_ethdev_vf.c
index f1341fbf7e..be96519b97 100644
--- a/drivers/net/txgbe/txgbe_ethdev_vf.c
+++ b/drivers/net/txgbe/txgbe_ethdev_vf.c
@@ -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.
