public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Andrew Fish <afish@apple.com>
To: Mike Kinney <michael.d.kinney@intel.com>
Cc: "Gao, Liming" <liming.gao@intel.com>,
	"Marvin.Haeuser@outlook.com" <Marvin.Haeuser@outlook.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [PATCH 1/1] MdePkg/Base.h: Implement BASE_CR() via OFFSET_OF().
Date: Fri, 02 Nov 2018 10:30:10 -0700	[thread overview]
Message-ID: <ED46BCAC-0D9F-447A-B901-B5C29B3B2E29@apple.com> (raw)
In-Reply-To: <E92EE9817A31E24EB0585FDF735412F5B8B28F8E@ORSMSX113.amr.corp.intel.com>

+1

Reviewed-by: Andrew Fish <afish@apple.com>

> On Nov 2, 2018, at 10:28 AM, Kinney, Michael D <michael.d.kinney@intel.com> wrote:
> 
> Marvin,
> 
> Thanks.  This is a good improvement.
> 
> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
> 
> Mike
> 
>> -----Original Message-----
>> From: Gao, Liming
>> Sent: Thursday, November 1, 2018 6:33 PM
>> To: Marvin.Haeuser@outlook.com; edk2-devel@lists.01.org
>> Cc: Kinney, Michael D <michael.d.kinney@intel.com>
>> Subject: RE: [PATCH 1/1] MdePkg/Base.h: Implement
>> BASE_CR() via OFFSET_OF().
>> 
>> The change is good. Reviewed-by: Liming Gao
>> <liming.gao@intel.com>
>> 
>>> -----Original Message-----
>>> From: edk2-devel [mailto:edk2-devel-
>> bounces@lists.01.org] On Behalf Of
>>> Marvin H?user
>>> Sent: Thursday, November 01, 2018 4:09 AM
>>> To: edk2-devel@lists.01.org
>>> Cc: Kinney, Michael D <michael.d.kinney@intel.com>;
>> Gao, Liming
>>> <liming.gao@intel.com>
>>> 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
>> <Marvin.Haeuser@outlook.com>
>>> ---
>>> 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
>>> edk2-devel@lists.01.org
>>> https://lists.01.org/mailman/listinfo/edk2-devel
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel



      reply	other threads:[~2018-11-02 17:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1541016342.git.Marvin.Haeuser@outlook.com>
2018-10-31 20:08 ` [PATCH 1/1] MdePkg/Base.h: Implement BASE_CR() via OFFSET_OF() Marvin Häuser
2018-11-02  1:32   ` Gao, Liming
2018-11-02 17:28     ` Kinney, Michael D
2018-11-02 17:30       ` Andrew Fish [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ED46BCAC-0D9F-447A-B901-B5C29B3B2E29@apple.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox