From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
edumazet@google.com, andrew+netdev@lunn.ch,
netdev@vger.kernel.org
Cc: Jakub Raczynski <j.raczynski@samsung.com>,
anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com,
kernel-janitors@vger.kernel.org, error27@gmail.com
Subject: [PATCH net-next 04/15] net/intel: Replace manual array size calculation with ARRAY_SIZE
Date: Tue, 9 Jun 2026 14:35:45 -0700 [thread overview]
Message-ID: <20260609213559.178657-5-anthony.l.nguyen@intel.com> (raw)
In-Reply-To: <20260609213559.178657-1-anthony.l.nguyen@intel.com>
From: Jakub Raczynski <j.raczynski@samsung.com>
There are still places in the code where manual calculation of array size
exist, but it is good to enforce usage of single macro through the whole
code as it makes code bit more readable.
While at it, beautify condition surrounding it by reversing check and remove
unnecessary casting.
Signed-off-by: Jakub Raczynski <j.raczynski@samsung.com>
Reviewed-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
drivers/net/ethernet/intel/i40e/i40e_adminq.h | 2 +-
drivers/net/ethernet/intel/iavf/iavf_adminq.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq.h b/drivers/net/ethernet/intel/i40e/i40e_adminq.h
index 1be97a3a86ce..dcf3baec7b73 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_adminq.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_adminq.h
@@ -109,7 +109,7 @@ static inline int i40e_aq_rc_to_posix(int aq_ret, int aq_rc)
-EFBIG, /* I40E_AQ_RC_EFBIG */
};
- if (!((u32)aq_rc < (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0]))))
+ if (aq_rc >= ARRAY_SIZE(aq_to_posix))
return -ERANGE;
return aq_to_posix[aq_rc];
diff --git a/drivers/net/ethernet/intel/iavf/iavf_adminq.h b/drivers/net/ethernet/intel/iavf/iavf_adminq.h
index bbf5c4b3a2ae..dd2f61172157 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_adminq.h
+++ b/drivers/net/ethernet/intel/iavf/iavf_adminq.h
@@ -113,7 +113,7 @@ static inline int iavf_aq_rc_to_posix(int aq_ret, int aq_rc)
if (aq_ret == IAVF_ERR_ADMIN_QUEUE_TIMEOUT)
return -EAGAIN;
- if (!((u32)aq_rc < (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0]))))
+ if (aq_rc >= ARRAY_SIZE(aq_to_posix))
return -ERANGE;
return aq_to_posix[aq_rc];
--
2.47.1
next prev parent reply other threads:[~2026-06-09 21:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 21:35 [PATCH net-next 00/15][pull request] Intel Wired LAN Driver Updates 2026-06-09 (idpf, ice, i40e, iavf, ixgbe, igc, igb, e1000e, e1000) Tony Nguyen
2026-06-09 21:35 ` [PATCH net-next 01/15] idpf: Replace use of system_unbound_wq with system_dfl_wq Tony Nguyen
2026-06-09 21:35 ` [PATCH net-next 02/15] ice: remove redundant checks from PTP init Tony Nguyen
2026-06-09 21:35 ` [PATCH net-next 03/15] iavf: iavf_virtchnl_completion: drop duplicate ether_addr_equal() test Tony Nguyen
2026-06-09 21:35 ` Tony Nguyen [this message]
2026-06-09 21:35 ` [PATCH net-next 05/15] ixgbe: e610: remove redundant assignment Tony Nguyen
2026-06-09 21:35 ` [PATCH net-next 06/15] igb: Retrieve Tx timestamp from BH workqueue Tony Nguyen
2026-06-12 9:57 ` Simon Horman
2026-06-09 21:35 ` [PATCH net-next 07/15] igb: use ktime_get_real helpers in igb_ptp_reset() Tony Nguyen
2026-06-09 21:35 ` [PATCH net-next 08/15] e1000e: use ktime_get_real_ns() in e1000e_systim_reset() Tony Nguyen
2026-06-09 21:35 ` [PATCH net-next 09/15] igb: use napi_schedule_irqoff() instead of napi_schedule() Tony Nguyen
2026-06-09 21:35 ` [PATCH net-next 10/15] igc: " Tony Nguyen
2026-06-09 21:35 ` [PATCH net-next 11/15] e1000e: Use __napi_schedule_irqoff() Tony Nguyen
2026-06-09 21:35 ` [PATCH net-next 12/15] e1000: limit endianness conversion to boundary words Tony Nguyen
2026-06-09 21:35 ` [PATCH net-next 13/15] e1000e: " Tony Nguyen
2026-06-09 21:35 ` [PATCH net-next 14/15] igb: fix typos in comments Tony Nguyen
2026-06-09 21:35 ` [PATCH net-next 15/15] igc: " Tony Nguyen
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=20260609213559.178657-5-anthony.l.nguyen@intel.com \
--to=anthony.l.nguyen@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=error27@gmail.com \
--cc=j.raczynski@samsung.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@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