lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <48D4F519.2080509@weinigel.se>
Date:	Sat, 20 Sep 2008 15:05:29 +0200
From:	Christer Weinigel <christer@...nigel.se>
To:	Alexey Dobriyan <adobriyan@...il.com>
CC:	Russ Dill <russ.dill@...il.com>, Eric Miao <eric.y.miao@...il.com>,
	Cyrill Gorcunov <gorcunov@...il.com>,
	linux-arm-kernel@...ts.arm.linux.org.uk,
	Ben Dooks <ben-linux@...ff.org>, linux-kernel@...r.kernel.org
Subject: Re: kernel.h: add ARRAY_AND_SIZE() macro to complement	ARRAY_SIZE().

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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ