macro.h: add sizeof_field() helper

Similar to kernel FIELD_SIZE()
This commit is contained in:
Marc-André Lureau 2020-05-17 15:25:14 +02:00
parent 00ebe01156
commit aaec2d7b9b
1 changed files with 2 additions and 0 deletions

View File

@ -448,6 +448,8 @@ static inline int __coverity_check_and_return__(int condition) {
#define char_array_0(x) x[sizeof(x)-1] = 0;
#define sizeof_field(struct_type, member) sizeof(((struct_type *) 0)->member)
/* Returns the number of chars needed to format variables of the
* specified type as a decimal string. Adds in extra space for a
* negative '-' prefix (hence works correctly on signed