+1 Reviewed-by: Andrew Fish <[email protected]>
> On Nov 2, 2018, at 10:28 AM, Kinney, Michael D <[email protected]> > wrote: > > Marvin, > > Thanks. This is a good improvement. > > Reviewed-by: Michael D Kinney <[email protected]> > > Mike > >> -----Original Message----- >> From: Gao, Liming >> Sent: Thursday, November 1, 2018 6:33 PM >> To: [email protected]; [email protected] >> Cc: Kinney, Michael D <[email protected]> >> Subject: RE: [PATCH 1/1] MdePkg/Base.h: Implement >> BASE_CR() via OFFSET_OF(). >> >> The change is good. Reviewed-by: Liming Gao >> <[email protected]> >> >>> -----Original Message----- >>> From: edk2-devel [mailto:edk2-devel- >> [email protected]] On Behalf Of >>> Marvin H?user >>> Sent: Thursday, November 01, 2018 4:09 AM >>> To: [email protected] >>> Cc: Kinney, Michael D <[email protected]>; >> Gao, Liming >>> <[email protected]> >>> Subject: [edk2] [PATCH 1/1] 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 >> <[email protected]> >>> --- >>> MdePkg/Include/Base.h | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/MdePkg/Include/Base.h >> b/MdePkg/Include/Base.h >>> index 523192fd79fc..bc877d8125a5 100644 >>> --- a/MdePkg/Include/Base.h >>> +++ b/MdePkg/Include/Base.h >>> @@ -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. >>> -- >>> 2.19.1.windows.1 >>> >>> _______________________________________________ >>> edk2-devel mailing list >>> [email protected] >>> https://lists.01.org/mailman/listinfo/edk2-devel > _______________________________________________ > edk2-devel mailing list > [email protected] > https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

