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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1437486658-28365-2-git-send-email-tomeu.vizoso@collabora.com>
Date:	Tue, 21 Jul 2015 15:50:43 +0200
From:	Tomeu Vizoso <tomeu.vizoso@...labora.com>
To:	linux-kernel@...r.kernel.org
Cc:	Stephen Warren <swarren@...dotorg.org>,
	"Rafael J. Wysocki" <rjw@...ysocki.net>,
	linux-arm-kernel@...ts.infradead.org,
	Arnd Bergmann <arnd@...db.de>, Mark Brown <broonie@...nel.org>,
	Tomeu Vizoso <tomeu.vizoso@...labora.com>
Subject: [RFC PATCH 01/16] typecheck_member and offsetof_t

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@...labora.com>
---

 include/linux/stddef.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/stddef.h b/include/linux/stddef.h
index 9c61c7cda936..e60bd164c03a 100644
--- a/include/linux/stddef.h
+++ b/include/linux/stddef.h
@@ -27,4 +27,11 @@ enum {
 #define offsetofend(TYPE, MEMBER) \
 	(offsetof(TYPE, MEMBER)	+ sizeof(((TYPE *)0)->MEMBER))
 
+#define typecheck_member(TYPE, MEMBER, MEMBERTYPE) \
+	((size_t)(&((TYPE *)0)->MEMBER - (MEMBERTYPE*)0) ? 0 : 0)
+
+/* like offsetof(), but ensures that MEMBER is of type MEMBERTYPE */
+#define offsetof_t(TYPE, MEMBER, MEMBERTYPE) \
+	(typecheck_member(TYPE, MEMBER, MEMBERTYPE) + offsetof(TYPE, MEMBER))
+
 #endif
-- 
2.4.3

--
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