Re: [PATCH 6/9] vdso: Split linux/array_size.h
From: Vincenzo Frascino
Date: Fri Sep 06 2024 - 07:42:23 EST
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@xxxxxxxxxx>
>> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
>> Cc: Jason A. Donenfeld <Jason@xxxxxxxxx>
>> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@xxxxxxx>
>> ---
>> 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