Re: [PATCH] fix sparse problems with ARRAY_SIZE

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

 



Adel Gadllah wrote:
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
resend the working one sorry.

Signed-off-by: Adel Gadllah <[email protected]>

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((arr)[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))

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux