* sparse and ARRAY_SIZE() foolproofing
@ 2007-06-05 14:18 Alexey Dobriyan
0 siblings, 0 replies; only message in thread
From: Alexey Dobriyan @ 2007-06-05 14:18 UTC (permalink / raw)
To: rusty, linux-kernel, linux-sparse
For every valid ARRAY_SIZE() use sparse warns about
"cannot size expression". This is somewhat annoying, because code is OK.
$ cat 1.c
#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
int f(void)
{
int a[42];
return ARRAY_SIZE(a);
}
$ sparse 1.c
1.c:9:9: error: cannot size expression
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-06-05 14:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-05 14:18 sparse and ARRAY_SIZE() foolproofing Alexey Dobriyan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).