Re: [PATCH 4/7] Compiler Attributes: homogenize __must_be_array
From: Miguel Ojeda
Date: Sat Sep 01 2018 - 08:12:23 EST
Hi Luc,
On Sat, Sep 1, 2018 at 11:17 AM, Luc Van Oostenryck
<luc.vanoostenryck@xxxxxxxxx> wrote:
> On Fri, Aug 31, 2018 at 07:05:11PM +0200, Miguel Ojeda wrote:
>> Different definitions of __must_be_array:
>>
>> * gcc: disabled for __CHECKER__
>> diff --git a/include/linux/compiler.h b/include/linux/compiler.h
>> index e0e55eb3f242..e4a702f99e50 100644
>> --- a/include/linux/compiler.h
>> +++ b/include/linux/compiler.h
>> @@ -357,4 +357,11 @@ static inline void *offset_to_ptr(const int *off)
>> compiletime_assert(__native_word(t), \
>> "Need native word sized stores/loads for atomicity.")
>>
>> +#ifdef __CHECKER__
>> +#define __must_be_array(a) 0
>> +#else
>> +/* &a[0] degrades to a pointer: a different type from an array */
>> +#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
>> +#endif
>> +
>> #endif /* __LINUX_COMPILER_H */
>
> You can also remove the #ifdef __CHECKER__ because:
> 1) even ancient version of sparse don't have a problem
> 2) BUILD_BUG_ON_ZERO() is currently disabled for __CHECKER__
>
Nice catch! Will do.
Cheers,
Miguel