[PATCH] fix sparse problems with ARRAY_SIZE
From: Adel Gadllah
Date: Tue Jul 10 2007 - 12:05:29 EST
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
Signed-off-by: Adel Gadllah <adel.gadllah@xxxxxxxxx>
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))