From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 B217C802B4 for ; Sun, 5 Mar 2017 17:37:43 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Mar 2017 17:37:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,251,1484035200"; d="scan'208";a="1105106103" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga001.jf.intel.com with ESMTP; 05 Mar 2017 17:37:43 -0800 Received: from fmsmsx116.amr.corp.intel.com (10.18.116.20) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 5 Mar 2017 17:37:43 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx116.amr.corp.intel.com (10.18.116.20) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 5 Mar 2017 17:37:42 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.177]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.204]) with mapi id 14.03.0248.002; Mon, 6 Mar 2017 09:37:38 +0800 From: "Tian, Feng" To: "Wu, Hao A" , "edk2-devel@lists.01.org" CC: "Zeng, Star" , "Tian, Feng" Thread-Topic: [PATCH v3 02/12] MdeModulePkg: Refine casting expression result to bigger size Thread-Index: AQHSjyXXOp3uYwfh0kaQrjfjbW1RzKGHFiqQ Date: Mon, 6 Mar 2017 01:37:37 +0000 Message-ID: <7F1BAD85ADEA444D97065A60D2E97EE5699B7446@SHSMSX101.ccr.corp.intel.com> References: <1487999555-9764-1-git-send-email-hao.a.wu@intel.com> <1487999555-9764-3-git-send-email-hao.a.wu@intel.com> In-Reply-To: <1487999555-9764-3-git-send-email-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 v3 02/12] MdeModulePkg: Refine casting expression result to bigger size X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Mar 2017 01:37:43 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Feng Tian Thanks Feng -----Original Message----- From: Wu, Hao A=20 Sent: Saturday, February 25, 2017 1:12 PM To: edk2-devel@lists.01.org Cc: Wu, Hao A ; Tian, Feng ; Zeng,= Star Subject: [PATCH v3 02/12] MdeModulePkg: Refine casting expression result to= bigger size There are cases that the operands of an expression are all with rank less than UINT64/INT64 and the result of the expression is explicitly cast to UINT64/INT64 to fit the target size. An example will be: UINT32 a,b; // a and b can be any unsigned int type with rank less than UINT64, like // UINT8, UINT16, etc. UINT64 c; c =3D (UINT64) (a + b); Some static code checkers may warn that the expression result might overflow within the rank of "int" (integer promotions) and the result is then cast to a bigger size. The commit refines codes by the following rules: 1). When the expression is possible to overflow the range of unsigned int/ int: c =3D (UINT64)a + b; 2). When the expression will not overflow within the rank of "int", remove the explicit type casts: c =3D a + b; 3). When the expression will be cast to pointer of possible greater size: UINT32 a,b; VOID *c; c =3D (VOID *)(UINTN)(a + b); --> c =3D (VOID *)((UINTN)a + b); 4). When one side of a comparison expression contains only operands with rank less than UINT32: UINT8 a; UINT16 b; UINTN c; if ((UINTN)(a + b) > c) {...} --> if (((UINT32)a + b) > c) {...} For rule 4), if we remove the 'UINTN' type cast like: if (a + b > c) {...} The VS compiler will complain with warning C4018 (signed/unsigned mismatch, level 3 warning) due to promoting 'a + b' to type 'int'. Cc: Feng Tian Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu --- MdeModulePkg/Application/UiApp/FrontPage.c = | 4 ++-- MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c = | 8 ++++---- MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c = | 4 ++-- MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c = | 2 +- MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c = | 20 ++++++++++---------- MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c = | 6 +++--- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c = | 6 +++--- MdeModulePkg/Core/Dxe/Image/Image.c = | 14 ++++++-------- MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c = | 4 ++-- MdeModulePkg/Core/Pei/Image/Image.c = | 12 +++++------- MdeModulePkg/Core/PiSmmCore/Dispatcher.c = | 18 ++++++++---------- MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c = | 12 +++++------- MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c = | 4 ++-- MdeModulePkg/Library/DxeCoreMemoryAllocationLib/MemoryAllocationLib.c = | 4 ++-- MdeModulePkg/Library/DxeNetLib/DxeNetLib.c = | 4 ++-- MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c = | 4 ++-- MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c = | 4 ++-- MdeModulePkg/Library/SmmMemoryAllocationProfileLib/MemoryAllocationLib.c = | 4 ++-- MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c = | 4 ++-- MdeModulePkg/Library/UefiHiiLib/HiiLib.c = | 4 ++-- MdeModulePkg/Library/UefiMemoryAllocationProfileLib/MemoryAllocationLib.c = | 4 ++-- MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c = | 6 +++--- MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c = | 4 ++-- MdeModulePkg/Universal/Acpi/S3SaveStateDxe/AcpiS3ContextSave.c = | 6 +++--- MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c = | 4 ++-- MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c = | 8 ++++---- MdeModulePkg/Universal/EbcDxe/EbcExecute.c = | 10 +++++----- MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c = | 4 ++-- MdeModulePkg/Universal/HiiDatabaseDxe/Font.c = | 20 ++++++++++---------- MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c = | 6 +++--- MdeModulePkg/Universal/PCD/Dxe/Service.c = | 4 ++-- MdeModulePkg/Universal/PCD/Pei/Service.c = | 4 ++-- MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c = | 6 +++--- MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c = | 6 +++--- 34 files changed, 113 insertions(+), 121 deletions(-) diff --git a/MdeModulePkg/Application/UiApp/FrontPage.c b/MdeModulePkg/Appl= ication/UiApp/FrontPage.c index bda5ff9..c2393eb 100644 --- a/MdeModulePkg/Application/UiApp/FrontPage.c +++ b/MdeModulePkg/Application/UiApp/FrontPage.c @@ -1,7 +1,7 @@ /** @file FrontPage routines to handle the callbacks and browser calls =20 -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at @@ -399,7 +399,7 @@ ConvertProcessorToString ( =20 if (Base10Exponent >=3D 6) { FreqMhz =3D ProcessorFrequency; - for (Index =3D 0; Index < (UINTN) (Base10Exponent - 6); Index++) { + for (Index =3D 0; Index < (UINT32) Base10Exponent - 6; Index++) { FreqMhz *=3D 10; } } else { diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c b/MdeModulePkg/Bus/Pci/= EhciDxe/EhciReg.c index 3a6ed02..34836ec 100644 --- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c +++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c @@ -2,7 +2,7 @@ =20 The EHCI register operation routines. =20 -Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at @@ -76,7 +76,7 @@ EhcReadDbgRegister ( Ehc->PciIo, EfiPciIoWidthUint32, Ehc->DebugPortBarNum, - (UINT64) (Ehc->DebugPortOffset + Offset), + Ehc->DebugPortOffset + Offset, 1, &Data ); @@ -115,7 +115,7 @@ EhcReadOpReg ( Ehc->PciIo, EfiPciIoWidthUint32, EHC_BAR_INDEX, - (UINT64) (Ehc->CapLen + Offset), + Ehc->CapLen + Offset, 1, &Data ); @@ -152,7 +152,7 @@ EhcWriteOpReg ( Ehc->PciIo, EfiPciIoWidthUint32, EHC_BAR_INDEX, - (UINT64) (Ehc->CapLen + Offset), + Ehc->CapLen + Offset, 1, &Data ); diff --git a/MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c b/MdeModulePkg/Bus/= Pci/IdeBusPei/AtapiPeim.c index be1b829..b1ab34d 100644 --- a/MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c +++ b/MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c @@ -5,7 +5,7 @@ ATA controllers in the platform. This PPI can be consumed by PEIM which produce gEfiPeiDeviceRecoveryModule= PpiGuid for Atapi CD ROM device. =20 -Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions @@ -593,7 +593,7 @@ AtapiEnumerateDevices ( // // Pata & Sata, Primary & Secondary channel, Master & Slave device // - DevicePosition =3D (UINTN) (Index1 * 2 + Index2); + DevicePosition =3D Index1 * 2 + Index2; =20 if (DiscoverAtapiDevice (AtapiBlkIoDev, DevicePosition, &MediaInfo, = &MediaInfo2)) { // diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c b/MdeModu= lePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c index d2ad94e..3713c07 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c @@ -305,7 +305,7 @@ GetOpRomInfo ( return EFI_NOT_FOUND; } =20 - PciIoDevice->RomSize =3D (UINT64) ((~AllOnes) + 1); + PciIoDevice->RomSize =3D (~AllOnes) + 1; return EFI_SUCCESS; } =20 diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c b/MdeModulePkg/Bus/Pci/= XhciDxe/XhciReg.c index 0e1c86c..4d5937d 100644 --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c @@ -2,7 +2,7 @@ =20 The XHCI register operation routines. =20 -Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at @@ -112,7 +112,7 @@ XhcReadOpReg ( Xhc->PciIo, EfiPciIoWidthUint32, XHC_BAR_INDEX, - (UINT64) (Xhc->CapLength + Offset), + Xhc->CapLength + Offset, 1, &Data ); @@ -148,7 +148,7 @@ XhcWriteOpReg ( Xhc->PciIo, EfiPciIoWidthUint32, XHC_BAR_INDEX, - (UINT64) (Xhc->CapLength + Offset), + Xhc->CapLength + Offset, 1, &Data ); @@ -181,7 +181,7 @@ XhcWriteOpReg16 ( Xhc->PciIo, EfiPciIoWidthUint16, XHC_BAR_INDEX, - (UINT64) (Xhc->CapLength + Offset), + Xhc->CapLength + Offset, 1, &Data ); @@ -215,7 +215,7 @@ XhcReadDoorBellReg ( Xhc->PciIo, EfiPciIoWidthUint32, XHC_BAR_INDEX, - (UINT64) (Xhc->DBOff + Offset), + Xhc->DBOff + Offset, 1, &Data ); @@ -251,7 +251,7 @@ XhcWriteDoorBellReg ( Xhc->PciIo, EfiPciIoWidthUint32, XHC_BAR_INDEX, - (UINT64) (Xhc->DBOff + Offset), + Xhc->DBOff + Offset, 1, &Data ); @@ -285,7 +285,7 @@ XhcReadRuntimeReg ( Xhc->PciIo, EfiPciIoWidthUint32, XHC_BAR_INDEX, - (UINT64) (Xhc->RTSOff + Offset), + Xhc->RTSOff + Offset, 1, &Data ); @@ -321,7 +321,7 @@ XhcWriteRuntimeReg ( Xhc->PciIo, EfiPciIoWidthUint32, XHC_BAR_INDEX, - (UINT64) (Xhc->RTSOff + Offset), + Xhc->RTSOff + Offset, 1, &Data ); @@ -355,7 +355,7 @@ XhcReadExtCapReg ( Xhc->PciIo, EfiPciIoWidthUint32, XHC_BAR_INDEX, - (UINT64) (Xhc->ExtCapRegBase + Offset), + Xhc->ExtCapRegBase + Offset, 1, &Data ); @@ -391,7 +391,7 @@ XhcWriteExtCapReg ( Xhc->PciIo, EfiPciIoWidthUint32, XHC_BAR_INDEX, - (UINT64) (Xhc->ExtCapRegBase + Offset), + Xhc->ExtCapRegBase + Offset, 1, &Data ); diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c b/MdeModulePkg/Bus= /Ufs/UfsBlockIoPei/UfsHci.c index 332ce7e..1ef6c88 100644 --- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -589,9 +589,9 @@ UfsCreateDMCommandDesc ( Trd->UcdBaU =3D (UINT32)RShiftU64 ((UINT64)(UINTN)QueryReqUpiu, 32); if (Opcode =3D=3D UtpQueryFuncOpcodeWrDesc) { Trd->RuL =3D (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_R= ESP_UPIU)), sizeof (UINT32)); - Trd->RuO =3D (UINT16)DivU64x32 ((UINT64)(ROUNDUP8 (sizeof (UTP_QUERY_= REQ_UPIU)) + ROUNDUP8 (DataSize)), sizeof (UINT32)); + Trd->RuO =3D (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_R= EQ_UPIU)) + ROUNDUP8 (DataSize), sizeof (UINT32)); } else { - Trd->RuL =3D (UINT16)DivU64x32 ((UINT64)(ROUNDUP8 (sizeof (UTP_QUERY_= RESP_UPIU)) + ROUNDUP8 (DataSize)), sizeof (UINT32)); + Trd->RuL =3D (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_R= ESP_UPIU)) + ROUNDUP8 (DataSize), sizeof (UINT32)); Trd->RuO =3D (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_R= EQ_UPIU)), sizeof (UINT32)); } =20 diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModu= lePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c index bc39cf8..3dd8cbf 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c @@ -2,7 +2,7 @@ UfsPassThruDxe driver is used to produce EFI_EXT_SCSI_PASS_THRU protocol= interface for upper layer application to execute UFS-supported SCSI cmds. =20 - Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -666,9 +666,9 @@ UfsCreateDMCommandDesc ( Trd->UcdBaU =3D (UINT32)RShiftU64 ((UINT64)CmdDescPhyAddr, 32); if (Opcode =3D=3D UtpQueryFuncOpcodeWrDesc) { Trd->RuL =3D (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_R= ESP_UPIU)), sizeof (UINT32)); - Trd->RuO =3D (UINT16)DivU64x32 ((UINT64)(ROUNDUP8 (sizeof (UTP_QUERY_= REQ_UPIU)) + ROUNDUP8 (DataSize)), sizeof (UINT32)); + Trd->RuO =3D (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_R= EQ_UPIU)) + ROUNDUP8 (DataSize), sizeof (UINT32)); } else { - Trd->RuL =3D (UINT16)DivU64x32 ((UINT64)(ROUNDUP8 (sizeof (UTP_QUERY_= RESP_UPIU)) + ROUNDUP8 (DataSize)), sizeof (UINT32)); + Trd->RuL =3D (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_R= ESP_UPIU)) + ROUNDUP8 (DataSize), sizeof (UINT32)); Trd->RuO =3D (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_R= EQ_UPIU)), sizeof (UINT32)); } =20 diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Im= age/Image.c index 652da8b..80128e7 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -313,8 +313,8 @@ CheckAndMarkFixLoadingMemoryUsageBitMap ( // // Test if the memory is avalaible or not. //=20 - BaseOffsetPageNumber =3D (UINTN)EFI_SIZE_TO_PAGES((UINT32)(ImageBase - = DxeCodeBase)); - TopOffsetPageNumber =3D (UINTN)EFI_SIZE_TO_PAGES((UINT32)(ImageBase + = ImageSize - DxeCodeBase)); + BaseOffsetPageNumber =3D EFI_SIZE_TO_PAGES((UINT32)(ImageBase - DxeCode= Base)); + TopOffsetPageNumber =3D EFI_SIZE_TO_PAGES((UINT32)(ImageBase + ImageSi= ze - DxeCodeBase)); for (Index =3D BaseOffsetPageNumber; Index < TopOffsetPageNumber; Index= ++) { if ((mDxeCodeMemoryRangeUsageBitMap[Index / 64] & LShiftU64(1, (Index= % 64))) !=3D 0) { // @@ -366,12 +366,10 @@ GetPeCoffImageFixLoadingAssignedAddress( // Handle =3D (IMAGE_FILE_HANDLE*)ImageContext->Handle; ImgHdr =3D (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((CHAR8* )Handle->Source = + ImageContext->PeCoffHeaderOffset); - SectionHeaderOffset =3D (UINTN)( - ImageContext->PeCoffHeaderOffset + - sizeof (UINT32) + - sizeof (EFI_IMAGE_FILE_HEADER) + - ImgHdr->Pe32.FileHeader.SizeOfOptionalHea= der - ); + SectionHeaderOffset =3D ImageContext->PeCoffHeaderOffset + + sizeof (UINT32) + + sizeof (EFI_IMAGE_FILE_HEADER) + + ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader; NumberOfSections =3D ImgHdr->Pe32.FileHeader.NumberOfSections; =20 // diff --git a/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c b/MdeModulePkg/Cor= e/Dxe/Misc/DebugImageInfo.c index 4766072..fda6d44 100644 --- a/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c +++ b/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c @@ -2,7 +2,7 @@ Support functions for managing debug image info table when loading and u= nloading images. =20 -Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at @@ -103,7 +103,7 @@ CoreInitializeDebugImageInfoTable ( Status =3D CoreFreePages (Memory, UnalignedPages); ASSERT_EFI_ERROR (Status); } - Memory =3D (EFI_PHYSICAL_ADDRESS)(AlignedMemory + EFI_PAGES_TO_S= IZE (Pages)); + Memory =3D AlignedMemory + EFI_PAGES_TO_SIZE (Pages); UnalignedPages =3D RealPages - Pages - UnalignedPages; if (UnalignedPages > 0) { // diff --git a/MdeModulePkg/Core/Pei/Image/Image.c b/MdeModulePkg/Core/Pei/Im= age/Image.c index d659de8..381a23f 100644 --- a/MdeModulePkg/Core/Pei/Image/Image.c +++ b/MdeModulePkg/Core/Pei/Image/Image.c @@ -1,7 +1,7 @@ /** @file Pei Core Load Image Support =20 -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at @@ -250,12 +250,10 @@ GetPeCoffImageFixLoadingAssignedAddress( SectionHeaderOffset =3D sizeof (EFI_TE_IMAGE_HEADER); NumberOfSections =3D ImgHdr->Te.NumberOfSections; } else { - SectionHeaderOffset =3D (UINTN)( - ImageContext->PeCoffHeaderOffset + - sizeof (UINT32) + - sizeof (EFI_IMAGE_FILE_HEADER) + - ImgHdr->Pe32.FileHeader.SizeOfOptionalHea= der - ); + SectionHeaderOffset =3D ImageContext->PeCoffHeaderOffset + + sizeof (UINT32) + + sizeof (EFI_IMAGE_FILE_HEADER) + + ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader; NumberOfSections =3D ImgHdr->Pe32.FileHeader.NumberOfSections; } // diff --git a/MdeModulePkg/Core/PiSmmCore/Dispatcher.c b/MdeModulePkg/Core/P= iSmmCore/Dispatcher.c index 1bddaf1..b2a6822 100644 --- a/MdeModulePkg/Core/PiSmmCore/Dispatcher.c +++ b/MdeModulePkg/Core/PiSmmCore/Dispatcher.c @@ -28,7 +28,7 @@ Depex - Dependency Expresion. =20 Copyright (c) 2014, Hewlett-Packard Development Company, L.P. - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availa= ble=20 under the terms and conditions of the BSD License which accompanies this= =20 distribution. The full text of the license may be found at =20 @@ -183,8 +183,8 @@ CheckAndMarkFixLoadingMemoryUsageBitMap ( // // Test if the memory is avalaible or not. //=20 - BaseOffsetPageNumber =3D (UINTN)EFI_SIZE_TO_PAGES((UINT32)(ImageBase - = SmmCodeBase)); - TopOffsetPageNumber =3D (UINTN)EFI_SIZE_TO_PAGES((UINT32)(ImageBase + = ImageSize - SmmCodeBase)); + BaseOffsetPageNumber =3D EFI_SIZE_TO_PAGES((UINT32)(ImageBase - SmmCode= Base)); + TopOffsetPageNumber =3D EFI_SIZE_TO_PAGES((UINT32)(ImageBase + ImageSi= ze - SmmCodeBase)); for (Index =3D BaseOffsetPageNumber; Index < TopOffsetPageNumber; Index= ++) { if ((mSmmCodeMemoryRangeUsageBitMap[Index / 64] & LShiftU64(1, (Index= % 64))) !=3D 0) { // @@ -234,12 +234,10 @@ GetPeCoffImageFixLoadingAssignedAddress( // Get PeHeader pointer // ImgHdr =3D (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((CHAR8* )ImageContext->Ha= ndle + ImageContext->PeCoffHeaderOffset); - SectionHeaderOffset =3D (UINTN)( - ImageContext->PeCoffHeaderOffset + - sizeof (UINT32) + - sizeof (EFI_IMAGE_FILE_HEADER) + - ImgHdr->Pe32.FileHeader.SizeOfOptionalHea= der - ); + SectionHeaderOffset =3D ImageContext->PeCoffHeaderOffset + + sizeof (UINT32) + + sizeof (EFI_IMAGE_FILE_HEADER) + + ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader; NumberOfSections =3D ImgHdr->Pe32.FileHeader.NumberOfSections; =20 // @@ -520,7 +518,7 @@ SmmLoadImage ( // Align buffer on section boundary // ImageContext.ImageAddress +=3D ImageContext.SectionAlignment - 1; - ImageContext.ImageAddress &=3D ~((EFI_PHYSICAL_ADDRESS)(ImageContext.Sec= tionAlignment - 1)); + ImageContext.ImageAddress &=3D ~((EFI_PHYSICAL_ADDRESS)ImageContext.Sect= ionAlignment - 1); =20 // // Load the image to our new buffer diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c b/MdeModulePkg/Core/PiS= mmCore/PiSmmIpl.c index 26b71f1..feb846e 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c @@ -846,12 +846,10 @@ GetPeCoffImageFixLoadingAssignedAddress( // Get PeHeader pointer // ImgHdr =3D (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((CHAR8* )ImageContext->H= andle + ImageContext->PeCoffHeaderOffset); - SectionHeaderOffset =3D (UINTN)( - ImageContext->PeCoffHeaderOffset + - sizeof (UINT32) + - sizeof (EFI_IMAGE_FILE_HEADER) + - ImgHdr->Pe32.FileHeader.SizeOfOptionalHea= der - ); + SectionHeaderOffset =3D ImageContext->PeCoffHeaderOffset + + sizeof (UINT32) + + sizeof (EFI_IMAGE_FILE_HEADER) + + ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader; NumberOfSections =3D ImgHdr->Pe32.FileHeader.NumberOfSections; =20 // @@ -1022,7 +1020,7 @@ ExecuteSmmCoreFromSmram ( } =20 ImageContext.ImageAddress +=3D ImageContext.SectionAlignment - 1; - ImageContext.ImageAddress &=3D ~((EFI_PHYSICAL_ADDRESS)(ImageContext.Sec= tionAlignment - 1)); + ImageContext.ImageAddress &=3D ~((EFI_PHYSICAL_ADDRESS)ImageContext.Sect= ionAlignment - 1); =20 // // Print debug message showing SMM Core load address. diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeMod= ulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c index d7abcc8..7f500a9 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c @@ -585,7 +585,7 @@ DisplayCapsuleImage ( EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; =20 ImagePayload =3D (DISPLAY_DISPLAY_PAYLOAD *)(CapsuleHeader + 1); - PayloadSize =3D (UINTN)(CapsuleHeader->CapsuleImageSize - sizeof(EFI_CAP= SULE_HEADER)); + PayloadSize =3D CapsuleHeader->CapsuleImageSize - sizeof(EFI_CAPSULE_HEA= DER); =20 if (ImagePayload->Version !=3D 1) { return EFI_UNSUPPORTED; @@ -733,7 +733,7 @@ DumpFmpCapsule ( for (Index =3D 0; Index < FmpCapsuleHeader->EmbeddedDriverCount; Index++= ) { DEBUG((DEBUG_VERBOSE, " ItemOffsetList[%d] - 0x%lx\n", Index, It= emOffsetList[Index])); } - for (; Index < (UINTN)(FmpCapsuleHeader->EmbeddedDriverCount + FmpCapsul= eHeader->PayloadItemCount); Index++) { + for (; Index < (UINT32)FmpCapsuleHeader->EmbeddedDriverCount + FmpCapsul= eHeader->PayloadItemCount; Index++) { DEBUG((DEBUG_VERBOSE, " ItemOffsetList[%d] - 0x%lx\n", Index, It= emOffsetList[Index])); ImageHeader =3D (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT= 8 *)FmpCapsuleHeader + ItemOffsetList[Index]); =20 diff --git a/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/MemoryAllocati= onLib.c b/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/MemoryAllocationL= ib.c index 89c19e7..95725c8 100644 --- a/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/MemoryAllocationLib.c +++ b/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/MemoryAllocationLib.c @@ -3,7 +3,7 @@ on DxeCore Memory Allocation services for DxeCore, with memory profile support. =20 - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials =20 are licensed and made available under the terms and conditions of the BS= D License =20 which accompanies this distribution. The full text of the license may b= e found at =20 @@ -258,7 +258,7 @@ InternalAllocateAlignedPages ( Status =3D CoreFreePages (Memory, UnalignedPages); ASSERT_EFI_ERROR (Status); } - Memory =3D (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_T= O_SIZE (Pages)); + Memory =3D AlignedMemory + EFI_PAGES_TO_SIZE (Pages); UnalignedPages =3D RealPages - Pages - UnalignedPages; if (UnalignedPages > 0) { // diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Libr= ary/DxeNetLib/DxeNetLib.c index 0a7117c..c015aa6 100644 --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c @@ -1,7 +1,7 @@ /** @file Network library. =20 -Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License @@ -3299,7 +3299,7 @@ NetLibGetSystemGuid ( return EFI_NOT_FOUND; } Smbios.Hdr =3D (SMBIOS_STRUCTURE *) (UINTN) SmbiosTable->TableAddre= ss; - SmbiosEnd.Raw =3D (UINT8 *) (UINTN) (SmbiosTable->TableAddress + Smbio= sTable->TableLength); + SmbiosEnd.Raw =3D (UINT8 *) ((UINTN) SmbiosTable->TableAddress + Smbio= sTable->TableLength); } =20 do { diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c b/M= deModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c index 1f8aaf4..fe2d3a0 100644 --- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c +++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c @@ -691,7 +691,7 @@ S3BootScriptGetBootTimeEntryAddAddress ( // Here we do not count the reserved memory for runtime script table. PageNumber =3D (UINT16) (mS3BootScriptTablePtr->TableMemoryPageNumber -= PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber)); TableLength =3D mS3BootScriptTablePtr->TableLength; - if ((UINTN) EFI_PAGES_TO_SIZE ((UINTN) PageNumber) < (UINTN) (TableLeng= th + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE))) { + if (EFI_PAGES_TO_SIZE ((UINTN) PageNumber) < (TableLength + EntryLength= + sizeof (EFI_BOOT_SCRIPT_TERMINATE))) { // // The buffer is too small to hold the table, Reallocate the buffer // @@ -752,7 +752,7 @@ S3BootScriptGetRuntimeEntryAddAddress ( // // Check if the memory range reserved for S3 Boot Script table is large= enough to hold the node. // - if ((UINTN) (mS3BootScriptTablePtr->TableLength + EntryLength + sizeof = (EFI_BOOT_SCRIPT_TERMINATE)) <=3D (UINTN) EFI_PAGES_TO_SIZE ((UINTN) (mS3Bo= otScriptTablePtr->TableMemoryPageNumber))) { + if ((mS3BootScriptTablePtr->TableLength + EntryLength + sizeof (EFI_BOO= T_SCRIPT_TERMINATE)) <=3D EFI_PAGES_TO_SIZE ((UINTN) (mS3BootScriptTablePtr= ->TableMemoryPageNumber))) { NewEntryPtr =3D mS3BootScriptTablePtr->TableBase + mS3BootScriptTable= Ptr->TableLength; mS3BootScriptTablePtr->TableLength =3D mS3BootScriptTablePtr->TableLe= ngth + EntryLength; // diff --git a/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAlloca= tionLib.c b/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocat= ionLib.c index bd21468..96cb275 100644 --- a/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib= .c +++ b/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib= .c @@ -11,7 +11,7 @@ In addition, allocation for the Reserved memory types are not supported = and will=20 always return NULL. =20 - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials =20 are licensed and made available under the terms and conditions of the BS= D License =20 which accompanies this distribution. The full text of the license may b= e found at =20 @@ -293,7 +293,7 @@ InternalAllocateAlignedPages ( Status =3D SmmFreePages (Memory, UnalignedPages); ASSERT_EFI_ERROR (Status); } - Memory =3D (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_T= O_SIZE (Pages)); + Memory =3D AlignedMemory + EFI_PAGES_TO_SIZE (Pages); UnalignedPages =3D RealPages - Pages - UnalignedPages; if (UnalignedPages > 0) { // diff --git a/MdeModulePkg/Library/SmmMemoryAllocationProfileLib/MemoryAlloc= ationLib.c b/MdeModulePkg/Library/SmmMemoryAllocationProfileLib/MemoryAlloc= ationLib.c index e9bbf02..2a18155 100644 --- a/MdeModulePkg/Library/SmmMemoryAllocationProfileLib/MemoryAllocationLi= b.c +++ b/MdeModulePkg/Library/SmmMemoryAllocationProfileLib/MemoryAllocationLi= b.c @@ -12,7 +12,7 @@ allocation for the Reserved memory types are not supported and will alwa= ys=20 return NULL. =20 - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials =20 are licensed and made available under the terms and conditions of the BS= D License =20 which accompanies this distribution. The full text of the license may b= e found at =20 @@ -371,7 +371,7 @@ InternalAllocateAlignedPages ( Status =3D gSmst->SmmFreePages (Memory, UnalignedPages); ASSERT_EFI_ERROR (Status); } - Memory =3D (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_T= O_SIZE (Pages)); + Memory =3D AlignedMemory + EFI_PAGES_TO_SIZE (Pages); UnalignedPages =3D RealPages - Pages - UnalignedPages; if (UnalignedPages > 0) { // diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c b/MdeModulePk= g/Library/UefiBootManagerLib/BmMisc.c index e11d842..11ab867 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c @@ -413,11 +413,11 @@ BmCharToUint ( ) { if ((Char >=3D L'0') && (Char <=3D L'9')) { - return (UINTN) (Char - L'0'); + return (Char - L'0'); } =20 if ((Char >=3D L'A') && (Char <=3D L'F')) { - return (UINTN) (Char - L'A' + 0xA); + return (Char - L'A' + 0xA); } =20 ASSERT (FALSE); diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Librar= y/UefiHiiLib/HiiLib.c index 8579501..0b5b0a9 100644 --- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c +++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c @@ -1,7 +1,7 @@ /** @file HII Library implementation that uses DXE protocols and services. =20 - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -1853,7 +1853,7 @@ GetBlockDataInfo ( // // Check whether VarBuffer is enough // - if ((UINTN) (Offset + Width) > MaxBufferSize) { + if ((UINT32)Offset + Width > MaxBufferSize) { DataBuffer =3D ReallocatePool ( MaxBufferSize, Offset + Width + HII_LIB_DEFAULT_VARSTORE_SIZE, diff --git a/MdeModulePkg/Library/UefiMemoryAllocationProfileLib/MemoryAllo= cationLib.c b/MdeModulePkg/Library/UefiMemoryAllocationProfileLib/MemoryAll= ocationLib.c index 370827d..cef7fc0 100644 --- a/MdeModulePkg/Library/UefiMemoryAllocationProfileLib/MemoryAllocationL= ib.c +++ b/MdeModulePkg/Library/UefiMemoryAllocationProfileLib/MemoryAllocationL= ib.c @@ -2,7 +2,7 @@ Support routines for memory allocation routines based=20 on boot services for Dxe phase drivers, with memory profile support. =20 - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials =20 are licensed and made available under the terms and conditions of the BS= D License =20 which accompanies this distribution. The full text of the license may b= e found at =20 @@ -257,7 +257,7 @@ InternalAllocateAlignedPages ( Status =3D gBS->FreePages (Memory, UnalignedPages); ASSERT_EFI_ERROR (Status); } - Memory =3D (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_T= O_SIZE (Pages)); + Memory =3D AlignedMemory + EFI_PAGES_TO_SIZE (Pages); UnalignedPages =3D RealPages - Pages - UnalignedPages; if (UnalignedPages > 0) { // diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c = b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c index b9ca908..93ff934 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c @@ -1,7 +1,7 @@ /** @file Var Check Hii handler. =20 -Copyright (c) 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at @@ -94,7 +94,7 @@ VarCheckHiiQuestion ( UINT8 Index; UINT8 MaxContainers; =20 - if ((UINTN) (HiiQuestion->VarOffset + HiiQuestion->StorageWidth) > DataS= ize) { + if (((UINT32) HiiQuestion->VarOffset + HiiQuestion->StorageWidth) > Data= Size) { DEBUG ((EFI_D_INFO, "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + St= orageWidth(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->S= torageWidth, DataSize)); return FALSE; } @@ -155,7 +155,7 @@ VarCheckHiiQuestion ( =20 case EFI_IFR_ORDERED_LIST_OP: MaxContainers =3D ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestio= n)->MaxContainers; - if ((UINTN) (HiiQuestion->VarOffset + HiiQuestion->StorageWidth * Ma= xContainers) > DataSize) { + if (((UINT32) HiiQuestion->VarOffset + HiiQuestion->StorageWidth * M= axContainers) > DataSize) { DEBUG ((EFI_D_INFO, "VarCheckHiiQuestion fail: (VarOffset(0x%04x) = + StorageWidth(0x%02x) * MaxContainers(0x%02x)) > Size(0x%x)\n", HiiQuestio= n->VarOffset, HiiQuestion->StorageWidth, MaxContainers, DataSize)); return FALSE; } diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecut= e.c b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c index f67fbca..16551ae 100644 --- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c +++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c @@ -4,7 +4,7 @@ This driver is dispatched by Dxe core and the driver will reload itself = to ACPI reserved memory in the entry point. The functionality is to interpret and restore the S3= boot script =20 -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License @@ -325,7 +325,7 @@ ReadyToLockEventNotify ( // Align buffer on section boundary // ImageContext.ImageAddress +=3D ImageContext.SectionAlignment - 1; - ImageContext.ImageAddress &=3D ~((EFI_PHYSICAL_ADDRESS)(ImageContext.Sec= tionAlignment - 1)); + ImageContext.ImageAddress &=3D ~((EFI_PHYSICAL_ADDRESS)ImageContext.Sect= ionAlignment - 1); // // Load the image to our new buffer // diff --git a/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/AcpiS3ContextSave.c= b/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/AcpiS3ContextSave.c index a973d2d..dcfd61c 100644 --- a/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/AcpiS3ContextSave.c +++ b/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/AcpiS3ContextSave.c @@ -1,7 +1,7 @@ /** @file This is the implementation to save ACPI S3 Context. =20 -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions @@ -401,9 +401,9 @@ S3AllocatePageTablesBuffer ( // We need calculate whole page size then allocate once, because S3 re= store page table does not know each page in Nvs. // if (!Page1GSupport) { - TotalPageTableSize =3D (UINTN)(1 + NumberOfPml4EntriesNeeded + Numbe= rOfPml4EntriesNeeded * NumberOfPdpEntriesNeeded); + TotalPageTableSize =3D 1 + NumberOfPml4EntriesNeeded + NumberOfPml4E= ntriesNeeded * NumberOfPdpEntriesNeeded; } else { - TotalPageTableSize =3D (UINTN)(1 + NumberOfPml4EntriesNeeded); + TotalPageTableSize =3D 1 + NumberOfPml4EntriesNeeded; } =20 TotalPageTableSize +=3D ExtraPageTablePages; diff --git a/MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c b/M= deModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c index 9e8315e..3e7054c 100644 --- a/MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c +++ b/MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c @@ -10,7 +10,7 @@ into memory. =20 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
-Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at @@ -1247,7 +1247,7 @@ CapsuleDataCoalesce ( // ASSERT (PrivateDataPtr->Signature =3D=3D EFI_CAPSULE_PEIM_PRIVATE_= DATA_SIGNATURE); ASSERT ((UINTN)DestPtr >=3D (UINTN)CapsuleImageBase); - PrivateDataPtr->CapsuleOffset[CapsuleIndex++] =3D (UINT64)((UINTN)= DestPtr - (UINTN)CapsuleImageBase); + PrivateDataPtr->CapsuleOffset[CapsuleIndex++] =3D (UINTN)DestPtr -= (UINTN)CapsuleImageBase; } =20 // diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c b/MdeMod= ulePkg/Universal/DisplayEngineDxe/FormDisplay.c index 0eb7ddd..e1ac5a3 100644 --- a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c +++ b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c @@ -1,7 +1,7 @@ /** @file Entry and initialization module for the browser. =20 -Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
Copyright (c) 2014, Hewlett-Packard Development Company, L.P.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License @@ -540,7 +540,7 @@ GetLineByWidth ( // // Need extra glyph info and '\0' info, so +2. // - *OutputString =3D AllocateZeroPool (((UINTN) (StrOffset + 2) * sizeof(CH= AR16))); + *OutputString =3D AllocateZeroPool ((StrOffset + 2) * sizeof(CHAR16)); if (*OutputString =3D=3D NULL) { return 0; } @@ -2972,7 +2972,7 @@ UiDisplayMenu ( gST->ConOut->SetAttribute (gST->ConOut, GetInfoTextColor ()); for (Index =3D 0; Index < HelpHeaderLine; Index++) { ASSERT (HelpHeaderLine =3D=3D 1); - ASSERT (GetStringWidth (HelpHeaderString) / 2 < (UINTN) (gHelpBl= ockWidth - 1)); + ASSERT (GetStringWidth (HelpHeaderString) / 2 < ((UINT32) gHelpB= lockWidth - 1)); PrintStringAtWithWidth ( gStatementDimensions.RightColumn - gHelpBlockWidth, Index + TopRow, @@ -3053,7 +3053,7 @@ UiDisplayMenu ( gST->ConOut->SetAttribute (gST->ConOut, GetInfoTextColor ()); for (Index =3D 0; Index < HelpBottomLine; Index++) { ASSERT (HelpBottomLine =3D=3D 1); - ASSERT (GetStringWidth (HelpBottomString) / 2 < (UINTN) (gHelpBl= ockWidth - 1));=20 + ASSERT (GetStringWidth (HelpBottomString) / 2 < ((UINT32) gHelpB= lockWidth - 1)); PrintStringAtWithWidth ( gStatementDimensions.RightColumn - gHelpBlockWidth, BottomRow + Index - HelpBottomLine + 1, diff --git a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c b/MdeModulePkg/Univ= ersal/EbcDxe/EbcExecute.c index e5d290a..2dfed8e 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcExecute.c @@ -1,7 +1,7 @@ /** @file Contains code that implements the virtual machine. =20 -Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at @@ -2867,7 +2867,7 @@ ExecutePOPn ( if (OPERAND1_INDIRECT (Operands)) { VmWriteMemN (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + = Index16), DataN); } else { - VmPtr->Gpr[OPERAND1_REGNUM (Operands)] =3D (INT64) (UINT64) ((UINTN) D= ataN + Index16); + VmPtr->Gpr[OPERAND1_REGNUM (Operands)] =3D (INT64) (UINT64) (UINTN) (D= ataN + Index16); } =20 return EFI_SUCCESS; @@ -3592,7 +3592,7 @@ ExecuteSUB ( if ((*VmPtr->Ip & DATAMANIP_M_64) !=3D 0) { return (UINT64) ((INT64) ((INT64) Op1 - (INT64) Op2)); } else { - return (UINT64) ((INT64) ((INT32) Op1 - (INT32) Op2)); + return (UINT64) ((INT64) ((INT32) ((INT32) Op1 - (INT32) Op2))); } } =20 @@ -3620,7 +3620,7 @@ ExecuteMUL ( if ((*VmPtr->Ip & DATAMANIP_M_64) !=3D 0) { return MultS64x64 ((INT64)Op1, (INT64)Op2); } else { - return (UINT64) ((INT64) ((INT32) Op1 * (INT32) Op2)); + return (UINT64) ((INT64) ((INT32) ((INT32) Op1 * (INT32) Op2))); } } =20 @@ -3648,7 +3648,7 @@ ExecuteMULU ( if ((*VmPtr->Ip & DATAMANIP_M_64) !=3D 0) { return MultU64x64 (Op1, Op2); } else { - return (UINT64) ((UINT32) Op1 * (UINT32) Op2); + return (UINT64) ((UINT32) ((UINT32) Op1 * (UINT32) Op2)); } } =20 diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBloc= k.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c index d46a37f..b4327b5 100644 --- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c +++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c @@ -2,7 +2,7 @@ =20 Internal functions to operate Working Block Space. =20 -Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials =20 are licensed and made available under the terms and conditions of the BSD = License =20 which accompanies this distribution. The full text of the license may be = found at =20 @@ -55,7 +55,7 @@ InitializeLocalWorkSpaceHeader ( &gEdkiiWorkingBlockSignatureGuid, sizeof (EFI_GUID) ); - mWorkingBlockHeader.WriteQueueSize =3D (UINT64) (PcdGet32 (PcdFlashNvSto= rageFtwWorkingSize) - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER)); + mWorkingBlockHeader.WriteQueueSize =3D PcdGet32 (PcdFlashNvStorageFtwWor= kingSize) - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER); =20 // // Crc is calculated with all the fields except Crc and STATE, so leave = them as FTW_ERASED_BYTE. diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c b/MdeModulePkg/Un= iversal/HiiDatabaseDxe/Font.c index 9bef064..b85cf88 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c @@ -2,7 +2,7 @@ Implementation for EFI_HII_FONT_PROTOCOL. =20 =20 -Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at @@ -411,7 +411,7 @@ GlyphToBlt ( // The glyph's upper left hand corner pixel is the most significant bit = of the // first bitmap byte. // - for (Ypos =3D 0; Ypos < Cell->Height && ((UINTN) (Ypos + YposOffset) < R= owHeight); Ypos++) { + for (Ypos =3D 0; Ypos < Cell->Height && (((UINT32) Ypos + YposOffset) < = RowHeight); Ypos++) { OffsetY =3D BITMAP_LEN_1_BIT (Cell->Width, Ypos); =20 // @@ -419,7 +419,7 @@ GlyphToBlt ( // for (Xpos =3D 0; Xpos < Cell->Width / 8; Xpos++) { Data =3D *(GlyphBuffer + OffsetY + Xpos); - for (Index =3D 0; Index < 8 && ((UINTN) (Xpos * 8 + Index + Cell->Of= fsetX) < RowWidth); Index++) { + for (Index =3D 0; Index < 8 && (((UINT32) Xpos * 8 + Index + Cell->O= ffsetX) < RowWidth); Index++) { if ((Data & (1 << (8 - Index - 1))) !=3D 0) { BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] =3D Foreground; } else { @@ -435,7 +435,7 @@ GlyphToBlt ( // There are some padding bits in this byte. Ignore them. // Data =3D *(GlyphBuffer + OffsetY + Xpos); - for (Index =3D 0; Index < Cell->Width % 8 && ((UINTN) (Xpos * 8 + In= dex + Cell->OffsetX) < RowWidth); Index++) { + for (Index =3D 0; Index < Cell->Width % 8 && (((UINT32) Xpos * 8 + I= ndex + Cell->OffsetX) < RowWidth); Index++) { if ((Data & (1 << (8 - Index - 1))) !=3D 0) { BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] =3D Foreground; } else { @@ -1927,7 +1927,7 @@ HiiStringToImage ( // If this character is the last character of a row, we need not // draw its (AdvanceX - Width - OffsetX) for next character. // - LineWidth -=3D (UINTN) (Cell[Index].AdvanceX - Cell[Index].Width - Cel= l[Index].OffsetX); + LineWidth -=3D (Cell[Index].AdvanceX - Cell[Index].Width - Cell[Index]= .OffsetX); =20 // // Clip the right-most character if cannot fit when EFI_HII_OUT_FLAG_C= LEAN_X is set. @@ -1950,8 +1950,8 @@ HiiStringToImage ( // // Don't draw the last char on this row. And, don't draw the secon= d last char (AdvanceX - Width - OffsetX). // - LineWidth -=3D (UINTN) (Cell[Index].Width + Cell[Index].OffsetX); - LineWidth -=3D (UINTN) (Cell[Index - 1].AdvanceX - Cell[Index - 1]= .Width - Cell[Index - 1].OffsetX); + LineWidth -=3D (Cell[Index].Width + Cell[Index].OffsetX); + LineWidth -=3D (Cell[Index - 1].AdvanceX - Cell[Index - 1].Width -= Cell[Index - 1].OffsetX); RowInfo[RowIndex].EndIndex =3D Index - 1; RowInfo[RowIndex].LineWidth =3D LineWidth; RowInfo[RowIndex].LineHeight =3D LineHeight; @@ -2008,7 +2008,7 @@ HiiStringToImage ( if (Index1 =3D=3D RowInfo[RowIndex].StartIndex) { LineWidth =3D 0; } else { - LineWidth -=3D (UINTN) (Cell[Index1 - 1].AdvanceX - Cell[Index= 1 - 1].Width - Cell[Index1 - 1].OffsetX); + LineWidth -=3D (Cell[Index1 - 1].AdvanceX - Cell[Index1 - 1].W= idth - Cell[Index1 - 1].OffsetX); } RowInfo[RowIndex].LineWidth =3D LineWidth; } @@ -2025,8 +2025,8 @@ HiiStringToImage ( // // Don't draw the last char on this row. And, don't draw the s= econd last char (AdvanceX - Width - OffsetX). // - LineWidth -=3D (UINTN) (Cell[Index1].Width + Cell[Index1].Offs= etX); - LineWidth -=3D (UINTN) (Cell[Index1 - 1].AdvanceX - Cell[Index= 1 - 1].Width - Cell[Index1 - 1].OffsetX); + LineWidth -=3D (Cell[Index1].Width + Cell[Index1].OffsetX); + LineWidth -=3D (Cell[Index1 - 1].AdvanceX - Cell[Index1 - 1].W= idth - Cell[Index1 - 1].OffsetX); RowInfo[RowIndex].EndIndex =3D Index1 - 1; RowInfo[RowIndex].LineWidth =3D LineWidth; } else { diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c b/MdeM= odulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c index 639da48..cd00f5c 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c @@ -1,7 +1,7 @@ /** @file Interface routines for PxeBc. =20 -Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at @@ -353,8 +353,8 @@ EfiPxeBcStart ( // // Configure block size for TFTP as a default value to handle all link l= ayers. //=20 - Private->BlockSize =3D (UINTN) (MIN (Private->Ip4MaxPacketSize, PXEBC_= DEFAULT_PACKET_SIZE) -=20 - PXEBC_DEFAULT_UDP_OVERHEAD_SIZE - PXEBC_DEFAULT= _TFTP_OVERHEAD_SIZE); + Private->BlockSize =3D MIN (Private->Ip4MaxPacketSize, PXEBC_DEFAULT_P= ACKET_SIZE) - + PXEBC_DEFAULT_UDP_OVERHEAD_SIZE - PXEBC_DEFAULT= _TFTP_OVERHEAD_SIZE; // // If PcdTftpBlockSize is set to non-zero, override the default value. // diff --git a/MdeModulePkg/Universal/PCD/Dxe/Service.c b/MdeModulePkg/Univer= sal/PCD/Dxe/Service.c index bf77130..efe7248 100644 --- a/MdeModulePkg/Universal/PCD/Dxe/Service.c +++ b/MdeModulePkg/Universal/PCD/Dxe/Service.c @@ -2,7 +2,7 @@ Help functions used by PCD DXE driver. =20 Copyright (c) 2014, Hewlett-Packard Development Company, L.P.
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
(C) Copyright 2016 Hewlett Packard Enterprise Development LP
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License @@ -452,7 +452,7 @@ GetWorker ( switch (LocalTokenNumber & PCD_TYPE_ALL_SET) { case PCD_TYPE_VPD: VpdHead =3D (VPD_HEAD *) ((UINT8 *) PcdDb + Offset); - RetPtr =3D (VOID *) (UINTN) (PcdGet32 (PcdVpdBaseAddress) + VpdHead-= >Offset); + RetPtr =3D (VOID *) ((UINTN) PcdGet32 (PcdVpdBaseAddress) + VpdHead-= >Offset); =20 break; =20 diff --git a/MdeModulePkg/Universal/PCD/Pei/Service.c b/MdeModulePkg/Univer= sal/PCD/Pei/Service.c index 66ca892..5e1cb72 100644 --- a/MdeModulePkg/Universal/PCD/Pei/Service.c +++ b/MdeModulePkg/Universal/PCD/Pei/Service.c @@ -2,7 +2,7 @@ The driver internal functions are implmented here. They build Pei PCD database, and provide access service to PCD database. =20 -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at @@ -985,7 +985,7 @@ GetWorker ( { VPD_HEAD *VpdHead; VpdHead =3D (VPD_HEAD *) ((UINT8 *)PeiPcdDb + Offset); - return (VOID *) (UINTN) (PcdGet32 (PcdVpdBaseAddress) + VpdHead->Off= set); + return (VOID *) ((UINTN) PcdGet32 (PcdVpdBaseAddress) + VpdHead->Off= set); } =20 case PCD_TYPE_HII|PCD_TYPE_STRING: diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c b/MdeModulePkg/Un= iversal/SmbiosDxe/SmbiosDxe.c index ea762d5..4e757e1 100644 --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c @@ -2,7 +2,7 @@ This code produces the Smbios protocol. It also responsible for construc= ting=20 SMBIOS table into system table. =20 -Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials =20 are licensed and made available under the terms and conditions of the BSD = License =20 which accompanies this distribution. The full text of the license may be = found at =20 @@ -1138,7 +1138,7 @@ SmbiosCreateTable ( EntryPointStructure->MaxStructureSize =3D (UINT16) sizeof (EndStructur= e); } =20 - if ((UINTN) EFI_SIZE_TO_PAGES (EntryPointStructure->TableLength) > mPreA= llocatedPages) { + if (EFI_SIZE_TO_PAGES ((UINT32) EntryPointStructure->TableLength) > mPre= AllocatedPages) { // // If new SMBIOS table size exceeds the previous allocated page,=20 // it is time to re-allocate memory (below 4GB). @@ -1307,7 +1307,7 @@ SmbiosCreate64BitTable ( EndStructure.Tailing[1] =3D 0; Smbios30EntryPointStructure->TableMaximumSize =3D (UINT32) (Smbios30Entr= yPointStructure->TableMaximumSize + sizeof (EndStructure)); =20 - if ((UINTN) EFI_SIZE_TO_PAGES (Smbios30EntryPointStructure->TableMaximum= Size) > mPre64BitAllocatedPages) { + if (EFI_SIZE_TO_PAGES (Smbios30EntryPointStructure->TableMaximumSize) > = mPre64BitAllocatedPages) { // // If new SMBIOS table size exceeds the previous allocated page,=20 // it is time to re-allocate memory at anywhere. diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeMod= ulePkg/Universal/Variable/RuntimeDxe/Variable.c index b0c7434..0a325de 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -3754,8 +3754,8 @@ InitNonVolatileVariableStore ( return EFI_VOLUME_CORRUPTED; } =20 - VariableStoreBase =3D (EFI_PHYSICAL_ADDRESS) ((UINTN) FvHeader + FvHeade= r->HeaderLength); - VariableStoreLength =3D (UINT64) (NvStorageSize - FvHeader->HeaderLength= ); + VariableStoreBase =3D (UINTN) FvHeader + FvHeader->HeaderLength; + VariableStoreLength =3D NvStorageSize - FvHeader->HeaderLength; =20 mNvFvHeaderCache =3D FvHeader; mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase =3D Variab= leStoreBase; @@ -4099,7 +4099,7 @@ VariableCommonInitialize ( GuidHob =3D GetFirstGuidHob (VariableGuid); if (GuidHob !=3D NULL) { VariableStoreHeader =3D GET_GUID_HOB_DATA (GuidHob); - VariableStoreLength =3D (UINT64) (GuidHob->Header.HobLength - sizeof (= EFI_HOB_GUID_TYPE)); + VariableStoreLength =3D GuidHob->Header.HobLength - sizeof (EFI_HOB_GU= ID_TYPE); if (GetVariableStoreStatus (VariableStoreHeader) =3D=3D EfiValid) { mVariableModuleGlobal->VariableGlobal.HobVariableBase =3D (EFI_PHYSI= CAL_ADDRESS) (UINTN) AllocateRuntimeCopyPool ((UINTN) VariableStoreLength, = (VOID *) VariableStoreHeader); if (mVariableModuleGlobal->VariableGlobal.HobVariableBase =3D=3D 0) = { --=20 1.9.5.msysgit.0