From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=17.151.62.66; helo=nwk-aaemail-lapp01.apple.com; envelope-from=afish@apple.com; receiver=edk2-devel@lists.01.org Received: from nwk-aaemail-lapp01.apple.com (nwk-aaemail-lapp01.apple.com [17.151.62.66]) (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 BD70021188C47 for ; Fri, 2 Nov 2018 10:30:19 -0700 (PDT) Received: from pps.filterd (nwk-aaemail-lapp01.apple.com [127.0.0.1]) by nwk-aaemail-lapp01.apple.com (8.16.0.22/8.16.0.22) with SMTP id wA2HMKGB053696; Fri, 2 Nov 2018 10:30:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apple.com; h=mime-version : content-transfer-encoding : content-type : sender : subject : from : in-reply-to : date : cc : message-id : references : to; s=20180706; bh=VeSCYwNODcNxr7wVZ8kryciB8+gWVQ6mbS1YqzCzSXg=; b=KVAT8vRkU7HY5e0T8xJRiSpPrZ9gOepzwnCUJqt3wdjINCDwVc97H0rfV6yqgh0vffFn N26AQEoRkbDt159QzgMbWv7KCZ7JpaybueSEXnDjBTWsfFT6nQRMVokwQYTX1rCNRPW6 EQUxjUcA/wL5LZVBUpOpNspMyHulmNKhZPTbORwVC3ufsRaj6y3HUmc2caIRK7lR1AkQ G+v0UZ4tUBhtJwTqEi0QgjVdYt9HRH5qZTLnapdRsAwROeBZN2Ghpndgw3uLVXgHchC1 50F/OKsoIKespqVmiHIjHdSljbF0LlpYrjn112iB4+m5YEzxiftVKeSZdGynyfEFjuAp 4A== Received: from ma1-mtap-s01.corp.apple.com (ma1-mtap-s01.corp.apple.com [17.40.76.5]) by nwk-aaemail-lapp01.apple.com with ESMTP id 2ncpyaq5b0-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Fri, 02 Nov 2018 10:30:19 -0700 MIME-version: 1.0 Received: from ma1-mmpp-sz07.apple.com (ma1-mmpp-sz07.apple.com [17.171.128.149]) by ma1-mtap-s01.corp.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) with ESMTPS id <0PHK00AXLTYF1P40@ma1-mtap-s01.corp.apple.com>; Fri, 02 Nov 2018 10:30:16 -0700 (PDT) Received: from process_viserion-daemon.ma1-mmpp-sz07.apple.com by ma1-mmpp-sz07.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) id <0PHK00B00TV5LB00@ma1-mmpp-sz07.apple.com>; Fri, 02 Nov 2018 10:30:15 -0700 (PDT) X-Va-A: X-Va-T-CD: cdf0b31a85bb8d396f4fbacc2efe7f8e X-Va-E-CD: 33c844c99c137b8669dfd872d4749f52 X-Va-R-CD: a5d1e79525304d5eb9a3773efee708ff X-Va-CD: 0 X-Va-ID: 8852c2d6-a84c-4f0a-8ae6-df035cf73209 X-V-A: X-V-T-CD: da3a4df698400084da27c6ab403bcb35 X-V-E-CD: 33c844c99c137b8669dfd872d4749f52 X-V-R-CD: a5d1e79525304d5eb9a3773efee708ff X-V-CD: 0 X-V-ID: 80858a24-b25c-443c-99dd-50bca7be9567 Received: from process_milters-daemon.ma1-mmpp-sz07.apple.com by ma1-mmpp-sz07.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) id <0PHK00B00TXPY400@ma1-mmpp-sz07.apple.com>; Fri, 02 Nov 2018 10:30:14 -0700 (PDT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-11-02_10:,, signatures=0 Received: from [17.234.195.53] (unknown [17.234.195.53]) by ma1-mmpp-sz07.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) with ESMTPSA id <0PHK00FOWTYBNC20@ma1-mmpp-sz07.apple.com>; Fri, 02 Nov 2018 10:30:14 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish In-reply-to: Date: Fri, 02 Nov 2018 10:30:10 -0700 Cc: "Gao, Liming" , "Marvin.Haeuser@outlook.com" , "edk2-devel@lists.01.org" Message-id: References: <4A89E2EF3DFEDB4C8BFDE51014F606A14E3637F5@SHSMSX104.ccr.corp.intel.com> To: Mike Kinney X-Mailer: Apple Mail (2.3445.6.18) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-02_10:, , signatures=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:30:19 -0000 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII +1 Reviewed-by: Andrew Fish > On Nov 2, 2018, at 10:28 AM, Kinney, Michael D wrote: > > 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(). >> >> The change is good. Reviewed-by: Liming Gao >> >> >>> -----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 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel