Re: [PATCH 6/9] vdso: Split linux/array_size.h

Vincenzo Frascino
2024-09-06T11:42:06Z

On 04/09/2024 18:18, Christophe Leroy wrote:
>
>
> Le 03/09/2024 à 17:14, Vincenzo Frascino a écrit :
>> The VDSO implementation includes headers from outside of the
>> vdso/ namespace.
>>
>> Split linux/array_size.h to make sure that the generic library
>> uses only the allowed namespace.
>
> There is only one place using ARRAY_SIZE(x), can be open coded as
> sizeof(x)/sizeof(*x) instead.
>

Agreed, as per previous comment on MIN()/MAX(). I will refactor my code accordingly.

> Christophe
>
>>
>> Cc: Andy Lutomirski <luto@kernel.org>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: Jason A. Donenfeld <Jason@zx2c4.com>
>> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
>> ---
>>   include/linux/array_size.h |  8 +-------
>>   include/vdso/array_size.h  | 13 +++++++++++++
>>   2 files changed, 14 insertions(+), 7 deletions(-)
>>   create mode 100644 include/vdso/array_size.h
>>
>> diff --git a/include/linux/array_size.h b/include/linux/array_size.h
>> index 06d7d83196ca..ca9e63b419c4 100644
>> --- a/include/linux/array_size.h
>> +++ b/include/linux/array_size.h
>> @@ -2,12 +2,6 @@
>>   #ifndef _LINUX_ARRAY_SIZE_H
>>   #define _LINUX_ARRAY_SIZE_H
>>   -#include <linux/compiler.h>
>> -
>> -/**
>> - * ARRAY_SIZE - get the number of elements in array @arr
>> - * @arr: array to be sized
>> - */
>> -#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
>> +#include <vdso/array_size.h>
>>     #endif  /* _LINUX_ARRAY_SIZE_H */
>> diff --git a/include/vdso/array_size.h b/include/vdso/array_size.h
>> new file mode 100644
>> index 000000000000..4079f7a5f86e
>> --- /dev/null
>> +++ b/include/vdso/array_size.h
>> @@ -0,0 +1,13 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +#ifndef _VDSO_ARRAY_SIZE_H
>> +#define _VDSO_ARRAY_SIZE_H
>> +
>> +#include <linux/compiler.h>
>> +
>> +/**
>> + * ARRAY_SIZE - get the number of elements in array @arr
>> + * @arr: array to be sized
>> + */
>> +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
>> +
>> +#endif  /* _VDSO_ARRAY_SIZE_H */

--
Regards,
Vincenzo