All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adel Gadllah <adel.gadllah@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fix sparse problems with ARRAY_SIZE
Date: Tue, 10 Jul 2007 18:09:48 +0200	[thread overview]
Message-ID: <4693AF4C.8010005@gmail.com> (raw)
In-Reply-To: <4693AE32.7030403@gmail.com>

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

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.


[-- Attachment #2: array_size_sparse_fix.patch --]
[-- Type: text/x-patch, Size: 729 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((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))

  reply	other threads:[~2007-07-10 16:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-10 16:05 [PATCH] fix sparse problems with ARRAY_SIZE Adel Gadllah
2007-07-10 16:09 ` Adel Gadllah [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4693AF4C.8010005@gmail.com \
    --to=adel.gadllah@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.