Google
  Web www.spinics.net

Re: [PATCH 3/8] drivers/media: use ARRAY_SIZE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


On Sun, 9 Nov 2008 09:14:27 -0800
Arjan van de Ven <arjan@xxxxxxxxxxxxx> wrote:

> On Sun, 9 Nov 2008 17:55:03 +0100 (CET)
> Julia Lawall <julia@xxxxxxx> wrote:
> 
> > From: Julia Lawall <julia@xxxxxxx>
> > 
> > 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.


_______________________________________________
v4l-dvb-maintainer mailing list
v4l-dvb-maintainer@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/v4l-dvb-maintainer

[Linux Media]     [Older V4L]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [SSH]     [Linux USB]

-->
Add to Google Powered by Linux

Google PageRank Checking tool