mirror of https://github.com/acidanthera/audk.git
MdePkg/Base.h: Implement BASE_CR() via OFFSET_OF().
Replace the current NULL pointer dereference to retrieve Field's offset with a call to OFFSET_OF(). This is implemented via __builtin_offsetof for GCC and Clang, which eliminates UB caught by Clang UndefinedBehaviorSanitizer. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
parent
88e8498f8a
commit
498cb29dfd
|
@ -869,7 +869,7 @@ typedef UINTN *BASE_LIST;
|
|||
@return A pointer to the structure from one of it's elements.
|
||||
|
||||
**/
|
||||
#define BASE_CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field)))
|
||||
#define BASE_CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - OFFSET_OF (TYPE, Field)))
|
||||
|
||||
/**
|
||||
Rounds a value up to the next boundary using a specified alignment.
|
||||
|
|
Loading…
Reference in New Issue