[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211119113644.1600-10-alx.manpages@gmail.com>
Date: Fri, 19 Nov 2021 12:36:37 +0100
From: Alejandro Colomar <alx.manpages@...il.com>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Alejandro Colomar <alx.manpages@...il.com>
Subject: [PATCH 09/17] linux/offsetof.h: Implement offsetof() in terms of memberof()
Use memberof() instead of explicitly dereferencing a null pointer.
Signed-off-by: Alejandro Colomar <alx.manpages@...il.com>
---
include/linux/offsetof.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/linux/offsetof.h b/include/linux/offsetof.h
index d0e2f1c34aae..809aed37ad29 100644
--- a/include/linux/offsetof.h
+++ b/include/linux/offsetof.h
@@ -3,13 +3,14 @@
#define _LINUX_OFFSETOF_H
#include <linux/compiler_types.h>
+#include <linux/memberof.h>
#undef offsetof
#ifdef __compiler_offsetof
#define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
#else
-#define offsetof(TYPE, MEMBER) ((size_t)&((TYPE *)0)->MEMBER)
+#define offsetof(TYPE, MEMBER) ((size_t)&memberof(TYPE, MEMBER))
#endif
--
2.33.1
Powered by blists - more mailing lists