lkml.org 
[lkml]   [2007]   [Jul]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] fix sparse problems with ARRAY_SIZE
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@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))
\
 
 \ /
  Last update: 2007-07-10 18:07    [W:0.055 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site