mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Roland McGrath <roland@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Vegard Nossum <vegard.nossum@gmail.com>
Subject: [PATCH] kmemcheck: clean up kmemcheck_annotate_bitfield
Date: Tue, 22 Sep 2009 17:13:01 -0700 (PDT)	[thread overview]
Message-ID: <20090923001301.3ED5922@magilla.sf.frob.com> (raw)

The commit 181f7c5dd3832763bdf2756b6d2d8a49bdf12791 change traded a
style warning from sparse for a syntax warning from the real compiler
(and perhaps an error with compilers old enough).  The use of a local
variable inside BUILD_BUG_ON() is pretty questionable too, though it
works with the compiler's constant-folding in practice.

This change cleans it all up a little more sanely.
The details are self-explanatory.

Signed-off-by: Roland McGrath <roland@redhat.com>
CC: Johannes Berg <johannes@sipsolutions.net>
CC: Vegard Nossum <vegard.nossum@gmail.com>
---
 include/linux/kmemcheck.h |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/include/linux/kmemcheck.h b/include/linux/kmemcheck.h
index c800660..9e2c5f4 100644
--- a/include/linux/kmemcheck.h
+++ b/include/linux/kmemcheck.h
@@ -143,16 +143,14 @@ static inline bool kmemcheck_is_obj_initialized(unsigned long addr, size_t size)
 #define kmemcheck_bitfield_end(name)	\
 	int name##_end[0];
 
+#define kmemcheck_bitfield_stretch(ptr, name)	\
+	((long) &(ptr)->name##_end - (long) &(ptr)->name##_begin)
+
 #define kmemcheck_annotate_bitfield(ptr, name)				\
 	do {								\
-		if (!ptr)						\
-			break;						\
-									\
-		int _n = (long) &((ptr)->name##_end)			\
-			- (long) &((ptr)->name##_begin);		\
-		BUILD_BUG_ON(_n < 0);					\
-									\
-		kmemcheck_mark_initialized(&((ptr)->name##_begin), _n);	\
+		BUILD_BUG_ON(kmemcheck_bitfield_stretch(ptr, name) < 0);\
+		kmemcheck_mark_initialized(&(ptr)->name##_begin,	\
+			kmemcheck_bitfield_stretch(ptr, name));		\
 	} while (0)
 
 #define kmemcheck_annotate_variable(var)				\

             reply	other threads:[~2009-09-23  0:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-23  0:13 Roland McGrath [this message]
2009-09-23  0:50 ` Andrew Morton

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=20090923001301.3ED5922@magilla.sf.frob.com \
    --to=roland@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®