From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=michael.d.kinney@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 56F0621188C53 for ; Fri, 2 Nov 2018 10:28:52 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Nov 2018 10:28:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,456,1534834800"; d="scan'208";a="101009271" Received: from orsmsx106.amr.corp.intel.com ([10.22.225.133]) by fmsmga002.fm.intel.com with ESMTP; 02 Nov 2018 10:28:50 -0700 Received: from orsmsx113.amr.corp.intel.com ([169.254.9.125]) by ORSMSX106.amr.corp.intel.com ([169.254.1.161]) with mapi id 14.03.0415.000; Fri, 2 Nov 2018 10:28:50 -0700 From: "Kinney, Michael D" To: "Gao, Liming" , "Marvin.Haeuser@outlook.com" , "edk2-devel@lists.01.org" , "Kinney, Michael D" Thread-Topic: [PATCH 1/1] MdePkg/Base.h: Implement BASE_CR() via OFFSET_OF(). Thread-Index: AQHUcVWBgAjGoTO9Pki8gs1UPnuKfaU7tOvwgAELMDA= Date: Fri, 2 Nov 2018 17:28:50 +0000 Message-ID: References: <4A89E2EF3DFEDB4C8BFDE51014F606A14E3637F5@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <4A89E2EF3DFEDB4C8BFDE51014F606A14E3637F5@SHSMSX104.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.22.254.138] MIME-Version: 1.0 Subject: Re: [PATCH 1/1] MdePkg/Base.h: Implement BASE_CR() via OFFSET_OF(). X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Nov 2018 17:28:52 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Marvin, Thanks. This is a good improvement. Reviewed-by: Michael D Kinney 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 > Subject: RE: [PATCH 1/1] MdePkg/Base.h: Implement > BASE_CR() via OFFSET_OF(). >=20 > The change is good. Reviewed-by: Liming Gao > >=20 > >-----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 ; > Gao, Liming > > > >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 > > >--- > > 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