All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christer Weinigel <christer@weinigel.se>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Russ Dill <russ.dill@gmail.com>,
	Eric Miao <eric.y.miao@gmail.com>,
	Cyrill Gorcunov <gorcunov@gmail.com>,
	linux-arm-kernel@lists.arm.linux.org.uk,
	Ben Dooks <ben-linux@fluff.org>,
	linux-kernel@vger.kernel.org
Subject: Re: kernel.h: add ARRAY_AND_SIZE() macro to complement	ARRAY_SIZE().
Date: Sat, 20 Sep 2008 15:05:29 +0200	[thread overview]
Message-ID: <48D4F519.2080509@weinigel.se> (raw)
In-Reply-To: <20080919175544.GA3228@x200.localdomain>

Alexey Dobriyan wrote:
> On Fri, Sep 19, 2008 at 08:28:45AM -0700, Russ Dill wrote:
>> My vote is for ARRAY_AND_SIZE to spread far and wide across the land.
>> ARRAY_SIZE is already very safe, as it has a __must_be_array macro
>> built in. So ARRAY_AND_SIZE is even safer, as it prevents you from
>> mixing up two different arrays. It also reduces line length and makes
>> driver and device (usually platform_device) registration code easier
>> to read.
> 
> It also spreads ARRAY_SIZE misnaming futher.

You still haven't explained what's misnamed about it, nor suggested a 
better name.

> It introduces one more core macro and quite pointless one. I can't
> personally recall a single bug where sizeof() was taken from another
> array.

You haven't written a lot of machine definitions then.  When adding 
platform devices for an embedded platform one has to write a lot of 
boilerplate like this:

     platform_add_devices(n30_devices, ARRAY_SIZE(n30_devices));

and it is much too easy to copy paste that line and miss one of the 
references.

> It creates interesting confusion point: ARRAY_AND_SIZE is about array
> and it's size. What ARRAY_SIZE is about then?

ARRAY_AND_SIZE -> (An) array and (its) size

ARRAY_SIZE -> (The) array size

Sure, you could write ARRAY_AND_ITS_SIZE, but would that really make 
anyone happy?  Cobol went out of fashion a long time ago.

   /Christer


  reply	other threads:[~2008-09-20 13:05 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
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 [this message]
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=48D4F519.2080509@weinigel.se \
    --to=christer@weinigel.se \
    --cc=adobriyan@gmail.com \
    --cc=ben-linux@fluff.org \
    --cc=eric.y.miao@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=russ.dill@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.