lkml.org 
[lkml]   [2008]   [Sep]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: kernel.h: add ARRAY_AND_SIZE() macro to complement ARRAY_SIZE().
[Christer Weinigel - Sat, Sep 20, 2008 at 06:38:51PM +0200]
> Cyrill Gorcunov wrote:
>> [Christer Weinigel - Sat, Sep 20, 2008 at 04:28:19PM +0200]
>> ...
>>> In my opinion, making platform_add_devices into a magic macro is
>>> actually worse, since the same construct (array, ARRAY_SIZE(array))
>>> is used in many places, so one would have to do the same thing over
>>> and over again for every function. In that case it's better to have
>>> to learn one macro once, and the ALL_CAPITALS should make it obvious
>>> that it is a macro.
>
>> Well, can't agree with you :) It's my _presonal_ opinion.
>> You could define it as
>>
>> static inline int platform_add_devices_array(struct platform_device **devs)
>> {
>> return platform_add_devices(devs, ARRAY_SIZE(devs));
>> }
>
> Won't work. You would have to use a macro. The above would turn into:
>
> platform_add_devices(devs, 1);
>
> or would if the __must_be_array check didn't catch it.
>
> /Christer
>

Ah...indeed, my bad :) gcc is not that smart (yet). So there only
the macro is possible (just forget that it will be different
namespace scope). Anyway even having it like a macro would be
better then hiding args.

- Cyrill -


\
 
 \ /
  Last update: 2008-09-20 19:15    [W:1.097 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site