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.65; helo=mga03.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 E59F621CF1CE5 for ; Mon, 12 Feb 2018 18:48:16 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Feb 2018 18:54:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,505,1511856000"; d="scan'208";a="27239846" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga003.jf.intel.com with ESMTP; 12 Feb 2018 18:54:06 -0800 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 12 Feb 2018 18:54:06 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 12 Feb 2018 18:54:05 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.124]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.130]) with mapi id 14.03.0319.002; Tue, 13 Feb 2018 10:54:04 +0800 From: "Zeng, Star" To: "Wu, Hao A" , "edk2-devel@lists.01.org" CC: "Kinney, Michael D" , Sean Brogan , "Yao, Jiewen" , "Dong, Eric" , "Ni, Ruiyu" , "Zeng, Star" Thread-Topic: [PATCH] MdeModulePkg/BmpSupportLib: Refine type cast for pointer subtraction Thread-Index: AQHTpHJMm7dK2MxQEEKebyPD/cwUXKOhotbA Date: Tue, 13 Feb 2018 02:54:03 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BA3F029@shsmsx102.ccr.corp.intel.com> References: <20180213022807.18288-1-hao.a.wu@intel.com> In-Reply-To: <20180213022807.18288-1-hao.a.wu@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdeModulePkg/BmpSupportLib: Refine type cast for pointer subtraction X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Feb 2018 02:48:17 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng Thanks, Star -----Original Message----- From: Wu, Hao A=20 Sent: Tuesday, February 13, 2018 10:28 AM To: edk2-devel@lists.01.org Cc: Wu, Hao A ; Kinney, Michael D ; Sean Brogan ; Yao, Jiewen ; Zeng, Star ; Dong, Eric ; Ni, Ruiyu Subject: [PATCH] MdeModulePkg/BmpSupportLib: Refine type cast for pointer s= ubtraction Since the pointer subtraction here is not performed by pointers to elements= of the same array object. This might lead to potential issues, such behavi= or is undefined according to C11 standard. Refine the pointer subtraction expressions by casting each pointer to UINTN= first and then perform the subtraction. Cc: Michael D Kinney Cc: Sean Brogan Cc: Jiewen Yao Cc: Star Zeng Cc: Eric Dong Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu --- MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c b/MdeMo= dulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c index 2c95e91ecc..467cd6a58d 100644 --- a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c +++ b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c @@ -426,7 +426,7 @@ TranslateBmpToGopBlt ( =20 } =20 - ImageIndex =3D (UINTN)(Image - ImageHeader); + ImageIndex =3D (UINTN)Image - (UINTN)ImageHeader; if ((ImageIndex % 4) !=3D 0) { // // Bmp Image starts each row on a 32-bit boundary! -- 2.12.0.windows.1