public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Eric Miao" <eric.y.miao@gmail.com>
To: "Alexey Dobriyan" <adobriyan@gmail.com>
Cc: "Ben Dooks" <ben-linux@fluff.org>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.arm.linux.org.uk
Subject: Re: kernel.h: add ARRAY_AND_SIZE() macro to complement ARRAY_SIZE().
Date: Fri, 19 Sep 2008 02:38:21 +0800	[thread overview]
Message-ID: <f17812d70809181138xb0e4d4bs8a6361bb038b5a6e@mail.gmail.com> (raw)
In-Reply-To: <20080918150624.GA3421@x200.localdomain>

On Thu, Sep 18, 2008 at 11:06 PM, Alexey Dobriyan <adobriyan@gmail.com> wrote:
> On Thu, Sep 18, 2008 at 02:24:47PM +0100, Ben Dooks wrote:
>> Move the ARRAY_AND_SIZE() macro from arch/arm/mach-pxa/generic.h
>> to a more useful position in include/linux/kernel.h. This macro
>> is very useful to registration functions that take an array and
>> the number of array elements in it as consecutive arguments.
>>
>> The macro also should ensure that mistakes where the wrong array
>> is used to the ARRAY_SIZE() macro is passed. It also makes it
>> easier to avoid wrapping registration function arguments.
>
>> --- linux-2.6.27-rc6-quilt4.orig/include/linux/kernel.h
>> +++ linux-2.6.27-rc6-quilt4/include/linux/kernel.h
>> @@ -43,6 +43,7 @@ extern const char linux_proc_banner[];
>>  #define IS_ALIGNED(x, a)             (((x) & ((typeof(x))(a) - 1)) == 0)
>>
>>  #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
>> +#define ARRAY_AND_SIZE(arr) (arr), ARRAY_SIZE(arr)
>
> Just like ARRAY_SIZE, it is misnamed.
>

Any hint about the correct spelling?

> And it isn't obvious to what it expands. Hopefully arm people will
> remove it. :-)

This is handy to use, saving several key strokes and making the line
shorter. If it's not obvious to what it expands, there must be some
fix for it?

  reply	other threads:[~2008-09-18 18:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-18 13:24 kernel.h: add ARRAY_AND_SIZE() macro to complement ARRAY_SIZE() Ben Dooks
2008-09-18 15:06 ` Alexey Dobriyan
2008-09-18 18:38   ` Eric Miao [this message]
2008-09-19  6:54     ` Cyrill Gorcunov
2008-09-19  7:22       ` Eric Miao
2008-09-19  7:32         ` Cyrill Gorcunov
2008-09-19 13:28         ` Stefan Richter
2008-09-19 15:28         ` Russ Dill
2008-09-19 17:55           ` Alexey Dobriyan
2008-09-20 13:05             ` Christer Weinigel
2008-09-20 13:45               ` Cyrill Gorcunov
2008-09-20 14:28                 ` Christer Weinigel
2008-09-20 14:45                   ` Cyrill Gorcunov
2008-09-20 16:38                     ` Christer Weinigel
2008-09-20 17:12                       ` Cyrill Gorcunov
2008-09-20 17:33                         ` Cyrill Gorcunov
2008-09-20 22:07               ` Chris Moore

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f17812d70809181138xb0e4d4bs8a6361bb038b5a6e@mail.gmail.com \
    --to=eric.y.miao@gmail.com \
    --cc=adobriyan@gmail.com \
    --cc=ben-linux@fluff.org \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox