lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20090923001301.3ED5922@magilla.sf.frob.com>
Date:	Tue, 22 Sep 2009 17:13:01 -0700 (PDT)
From:	Roland McGrath <roland@...hat.com>
To:	Andrew Morton <akpm@...ux-foundation.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>
Cc:	Vegard Nossum <vegard.nossum@...il.com>
Subject: [PATCH] kmemcheck: clean up kmemcheck_annotate_bitfield

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@...hat.com>
CC: Johannes Berg <johannes@...solutions.net>
CC: Vegard Nossum <vegard.nossum@...il.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)				\
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ