]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net/intel: Replace manual array size calculation with ARRAY_SIZE
authorJakub Raczynski <j.raczynski@samsung.com>
Tue, 9 Jun 2026 21:35:45 +0000 (14:35 -0700)
committerJakub Kicinski <kuba@kernel.org>
Sat, 13 Jun 2026 23:43:47 +0000 (16:43 -0700)
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>
Link: https://patch.msgid.link/20260609213559.178657-5-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/intel/i40e/i40e_adminq.h
drivers/net/ethernet/intel/iavf/iavf_adminq.h

index 1be97a3a86ced3cb93ab5d922f7a2eb6ddb842d1..dcf3baec7b73561d02a0eba4fe17db147f9285d2 100644 (file)
@@ -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];
index bbf5c4b3a2aef0499e9a8ba40414504df518bb14..dd2f61172157a9f26f315e6935d29150470adb7b 100644 (file)
@@ -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];