Messages in this thread Patch in this message | | | From | Alejandro Colomar <> | Subject | [PATCH 09/17] linux/offsetof.h: Implement offsetof() in terms of memberof() | Date | Fri, 19 Nov 2021 12:36:37 +0100 |
| |
Use memberof() instead of explicitly dereferencing a null pointer.
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.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
| |