From aaec2d7b9b4756e5600d132e1a179f8bdce99945 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marc-Andr=C3=A9=20Lureau?= Date: Sun, 17 May 2020 15:25:14 +0200 Subject: [PATCH] macro.h: add sizeof_field() helper Similar to kernel FIELD_SIZE() --- src/basic/macro.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/basic/macro.h b/src/basic/macro.h index b48d399097..78e4262e41 100644 --- a/src/basic/macro.h +++ b/src/basic/macro.h @@ -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 -- 2.25.1