public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix sparse problems with ARRAY_SIZE
@ 2007-07-10 16:05 Adel Gadllah
  2007-07-10 16:09 ` Adel Gadllah
  0 siblings, 1 reply; 6+ messages in thread
From: Adel Gadllah @ 2007-07-10 16:05 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 253 bytes --]

ARRAY_SIZE seems to create sparse warnings when used on global 
variables. The attached patch fixes this by using a ARRAY_SIZE macro 
that does not use __must_be_array(arr) for sparse.
See: http://marc.info/?t=118103449100007&r=1&w=2

P.S: please CC me

[-- Attachment #2: array_size_sparse_fix.patch --]
[-- Type: text/x-patch, Size: 727 bytes --]

Signed-off-by: Adel Gadllah <adel.gadllah@gmail.com>

diff -upNr linux-2.6.orig/include/linux/kernel.h linux-2.6/include/linux/kernel.h
--- linux-2.6.orig/include/linux/kernel.h	2007-07-10 17:53:39.000000000 +0200
+++ linux-2.6/include/linux/kernel.h	2007-07-10 18:01:30.000000000 +0200
@@ -35,7 +35,11 @@ extern const char linux_proc_banner[];
 #define ALIGN(x,a)		__ALIGN_MASK(x,(typeof(x))(a)-1)
 #define __ALIGN_MASK(x,mask)	(((x)+(mask))&~(mask))
 
+#ifdef __CHECKER_
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((x)[0]))
+#else
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
+#endif
 
 #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-07-12 10:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-10 16:05 [PATCH] fix sparse problems with ARRAY_SIZE Adel Gadllah
2007-07-10 16:09 ` Adel Gadllah
2007-07-10 19:40   ` Alexey Dobriyan
2007-07-10 20:58     ` Al Viro
2007-07-10 22:40       ` Al Viro
2007-07-12 10:27         ` Adel Gadllah

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox