public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gao, Liming" <liming.gao@intel.com>
To: "Marvin.Haeuser@outlook.com" <Marvin.Haeuser@outlook.com>,
	"edk2-devel@lists.01.org" <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().
Date: Fri, 2 Nov 2018 01:32:32 +0000	[thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E3637F5@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <VI1PR0801MB179033818B86307069439A4080CD0@VI1PR0801MB1790.eurprd08.prod.outlook.com>

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


  reply	other threads:[~2018-11-02  1:32 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 [this message]
2018-11-02 17:28     ` Kinney, Michael D
2018-11-02 17:30       ` Andrew Fish

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=4A89E2EF3DFEDB4C8BFDE51014F606A14E3637F5@SHSMSX104.ccr.corp.intel.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