diff mbox series

net/mlx4: Use ARRAY_SIZE to get an array's size

Message ID 20210817121106.44189-1-wangborong@cdjrlc.com (mailing list archive)
State Not Applicable
Headers show
Series net/mlx4: Use ARRAY_SIZE to get an array's size | expand

Commit Message

Jason Wang Aug. 17, 2021, 12:11 p.m. UTC
The ARRAY_SIZE macro is defined to get an array's size which is
more compact and more formal in linux source. Thus, we can replace
the long sizeof(arr)/sizeof(arr[0]) with the compact ARRAY_SIZE.

Signed-off-by: Jason Wang <wangborong@cdjrlc.com>
---
 drivers/net/ethernet/mellanox/mlx4/qp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Joe Perches Aug. 18, 2021, 12:39 a.m. UTC | #1
On Tue, 2021-08-17 at 20:11 +0800, Jason Wang wrote:
> The ARRAY_SIZE macro is defined to get an array's size which is
> more compact and more formal in linux source. Thus, we can replace
> the long sizeof(arr)/sizeof(arr[0]) with the compact ARRAY_SIZE.
[]
> diff --git a/drivers/net/ethernet/mellanox/mlx4/qp.c b/drivers/net/ethernet/mellanox/mlx4/qp.c
[]
> @@ -739,7 +739,7 @@ static void mlx4_cleanup_qp_zones(struct mlx4_dev *dev)
>  		int i;
>  
> 
>  		for (i = 0;
> -		     i < sizeof(qp_table->zones_uids)/sizeof(qp_table->zones_uids[0]);
> +		     i < ARRAY_SIZE(qp_table->zones_uids);
>  		     i++) {

trivia:  could now be a single line

		for (i = 0; i < ARRAY_SIZE(qp_table->zones_uids); i++) {
Tariq Toukan Aug. 18, 2021, 12:28 p.m. UTC | #2
On 8/18/2021 3:39 AM, Joe Perches wrote:
> On Tue, 2021-08-17 at 20:11 +0800, Jason Wang wrote:
>> The ARRAY_SIZE macro is defined to get an array's size which is
>> more compact and more formal in linux source. Thus, we can replace
>> the long sizeof(arr)/sizeof(arr[0]) with the compact ARRAY_SIZE.
> []
>> diff --git a/drivers/net/ethernet/mellanox/mlx4/qp.c b/drivers/net/ethernet/mellanox/mlx4/qp.c
> []
>> @@ -739,7 +739,7 @@ static void mlx4_cleanup_qp_zones(struct mlx4_dev *dev)
>>   		int i;
>>   
>>
>>   		for (i = 0;
>> -		     i < sizeof(qp_table->zones_uids)/sizeof(qp_table->zones_uids[0]);
>> +		     i < ARRAY_SIZE(qp_table->zones_uids);
>>   		     i++) {
> 
> trivia:  could now be a single line
> 
> 		for (i = 0; i < ARRAY_SIZE(qp_table->zones_uids); i++) {
> 
> 

I'm fine with both suggestions.
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>

Thanks for your patch.
Tariq
patchwork-bot+netdevbpf@kernel.org Aug. 18, 2021, 10:20 p.m. UTC | #3
Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Tue, 17 Aug 2021 20:11:06 +0800 you wrote:
> The ARRAY_SIZE macro is defined to get an array's size which is
> more compact and more formal in linux source. Thus, we can replace
> the long sizeof(arr)/sizeof(arr[0]) with the compact ARRAY_SIZE.
> 
> Signed-off-by: Jason Wang <wangborong@cdjrlc.com>
> ---
>  drivers/net/ethernet/mellanox/mlx4/qp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
  - net/mlx4: Use ARRAY_SIZE to get an array's size
    https://git.kernel.org/netdev/net-next/c/19b8ece42c56

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx4/qp.c b/drivers/net/ethernet/mellanox/mlx4/qp.c
index 2584bc038f94..b149e601f673 100644
--- a/drivers/net/ethernet/mellanox/mlx4/qp.c
+++ b/drivers/net/ethernet/mellanox/mlx4/qp.c
@@ -739,7 +739,7 @@  static void mlx4_cleanup_qp_zones(struct mlx4_dev *dev)
 		int i;
 
 		for (i = 0;
-		     i < sizeof(qp_table->zones_uids)/sizeof(qp_table->zones_uids[0]);
+		     i < ARRAY_SIZE(qp_table->zones_uids);
 		     i++) {
 			struct mlx4_bitmap *bitmap =
 				mlx4_zone_get_bitmap(qp_table->zones,