From: Andrew Morton <akpm@linux-foundation.org>
To: Arjan van de Ven <arjan@infradead.org>
Cc: julia@diku.dk, mchehab@infradead.org,
v4l-dvb-maintainer@linuxtv.org, video4linux-list@redhat.com,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 3/8] drivers/media: use ARRAY_SIZE
Date: Wed, 12 Nov 2008 15:17:42 -0800 [thread overview]
Message-ID: <20081112151742.a0da237c.akpm@linux-foundation.org> (raw)
In-Reply-To: <20081109091427.1d6bdfcd@infradead.org>
On Sun, 9 Nov 2008 09:14:27 -0800
Arjan van de Ven <arjan@infradead.org> wrote:
> On Sun, 9 Nov 2008 17:55:03 +0100 (CET)
> Julia Lawall <julia@diku.dk> wrote:
>
> > From: Julia Lawall <julia@diku.dk>
> >
> > ARRAY_SIZE is more concise to use when the size of an array is
> > divided by the size of its type or the size of its first element.
>
> Hi,
> looking at your patch, I don't think I agree it's just blindly the
> right thing to do.
>
> > - *count = sizeof(RegAddr) / sizeof(u8);
> > + *count = ARRAY_SIZE(RegAddr);
It looks OK to me?
u8 RegAddr[] = {
11, 12, 13, 22, 32, 43, 44, 53, 56, 59, 73,
76, 77, 91, 134, 135, 137, 147,
156, 166, 167, 168, 25 };
*count = sizeof(RegAddr) / sizeof(u8);
> really. ARRAY_SIZE doesn't appear to be an improvement here..
It's a pretty typical usage of ARRAY_SIZE. The benefits are, as usual:
- the ARRAY_SIZE construct *tells* the reader what the code is trying
to do. Rather than the reader having to work it out and then say "oh
yeah, that's what it's doing".
- a reviewer doesn't have to go back and double-check that correct
type was used.
prev parent reply other threads:[~2008-11-12 23:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-09 16:55 Julia Lawall
2008-11-09 17:14 ` Arjan van de Ven
2008-11-12 23:17 ` Andrew Morton [this message]
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=20081112151742.a0da237c.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=arjan@infradead.org \
--cc=julia@diku.dk \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@infradead.org \
--cc=v4l-dvb-maintainer@linuxtv.org \
--cc=video4linux-list@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®