diff options
author | Alejandro Colomar <alx.manpages@gmail.com> | 2021-11-19 13:01:07 +0100 |
---|---|---|
committer | Alejandro Colomar <alx.manpages@gmail.com> | 2021-11-19 13:01:07 +0100 |
commit | 36561e745fa71bb053ab18396934ca9da9da7128 (patch) | |
tree | e1140fb4c918138526d6493bfdd7a6b4ccae99d6 | |
parent | 899f6f01632a2810367d79a56c494a823f320d0f (diff) |
linux/sizeof_field.h: Implement sizeof_field() in terms of memberof()fieldof
Use memberof() instead of explicitly dereferencing a null pointer.
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
-rw-r--r-- | include/linux/sizeof_field.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/include/linux/sizeof_field.h b/include/linux/sizeof_field.h index 7ff541cb21af..96aa05c90076 100644 --- a/include/linux/sizeof_field.h +++ b/include/linux/sizeof_field.h @@ -2,13 +2,16 @@ #ifndef _LINUX_SIZEOF_FIELD_H #define _LINUX_SIZEOF_FIELD_H +#include <linux/memberof.h> + + /** * sizeof_field() - Report the size of a struct field in bytes * * @TYPE: The structure containing the field of interest * @MEMBER: The field to return the size of */ -#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) +#define sizeof_field(TYPE, MEMBER) sizeof(memberof(TYPE, MEMBER)) #endif /* _LINUX_SIZEOF_FIELD_H */ |