From: Lennart Poettering Date: Thu, 18 Oct 2018 15:10:42 +0000 (+0200) Subject: efi: rework OFFSETOF() based on __builtin_offsetof() X-Git-Tag: v240~518 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0fef9583615435d41a7724b0c49f530433b4c572;p=thirdparty%2Fsystemd.git efi: rework OFFSETOF() based on __builtin_offsetof() Since both LLVM and gcc supported this for a long time, we are not adding a fallback compat kludge. And even if there's some relevant compiler that doesn't know this concept, it'll fail with a compiler error, and we'll fix it then. As suggested by @keszybz: https://github.com/systemd/systemd/pull/10174#discussion_r226266540 --- diff --git a/src/boot/efi/util.h b/src/boot/efi/util.h index 40ede66d4a9..daa386b7696 100644 --- a/src/boot/efi/util.h +++ b/src/boot/efi/util.h @@ -5,7 +5,7 @@ #include #define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0])) -#define OFFSETOF(x,y) ((UINTN) &(((x*)0)->y)) +#define OFFSETOF(x,y) __builtin_offsetof(x,y) static inline const CHAR16 *yes_no(BOOLEAN b) { return b ? L"yes" : L"no";