]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Refine casting expression result to bigger size
authorHao Wu <hao.a.wu@intel.com>
Fri, 24 Feb 2017 02:01:34 +0000 (10:01 +0800)
committerHao Wu <hao.a.wu@intel.com>
Mon, 6 Mar 2017 06:33:20 +0000 (14:33 +0800)
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 = (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 = (UINT64)a + b;

2). When the expression will not overflow within the rank of "int", remove
the explicit type casts:
c = a + b;

3). When the expression will be cast to pointer of possible greater size:
UINT32 a,b;
VOID *c;
c = (VOID *)(UINTN)(a + b); --> c = (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'.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
34 files changed:
MdeModulePkg/Application/UiApp/FrontPage.c
MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c
MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c
MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c
MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
MdeModulePkg/Core/Dxe/Image/Image.c
MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c
MdeModulePkg/Core/Pei/Image/Image.c
MdeModulePkg/Core/PiSmmCore/Dispatcher.c
MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
MdeModulePkg/Library/DxeCoreMemoryAllocationLib/MemoryAllocationLib.c
MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c
MdeModulePkg/Library/SmmMemoryAllocationProfileLib/MemoryAllocationLib.c
MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
MdeModulePkg/Library/UefiHiiLib/HiiLib.c
MdeModulePkg/Library/UefiMemoryAllocationProfileLib/MemoryAllocationLib.c
MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c
MdeModulePkg/Universal/Acpi/S3SaveStateDxe/AcpiS3ContextSave.c
MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c
MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
MdeModulePkg/Universal/EbcDxe/EbcExecute.c
MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
MdeModulePkg/Universal/PCD/Dxe/Service.c
MdeModulePkg/Universal/PCD/Pei/Service.c
MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c

index ad5af2cebbd3a54d0af90cd02fccacb053dee52f..adee67a8ac142c4d3c0f7d2016613881c6ca2d3f 100644 (file)
@@ -399,7 +399,7 @@ ConvertProcessorToString (
 \r
   if (Base10Exponent >= 6) {\r
     FreqMhz = ProcessorFrequency;\r
-    for (Index = 0; Index < (UINTN) (Base10Exponent - 6); Index++) {\r
+    for (Index = 0; Index < (UINT32) Base10Exponent - 6; Index++) {\r
       FreqMhz *= 10;\r
     }\r
   } else {\r
index 3a6ed02be77c72cbbd0202871c50e1e22b5abfc9..34836eccf5fbda634c8d405c7e66499e1154c352 100644 (file)
@@ -2,7 +2,7 @@
 \r
   The EHCI register operation routines.\r
 \r
-Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -76,7 +76,7 @@ EhcReadDbgRegister (
                              Ehc->PciIo,\r
                              EfiPciIoWidthUint32,\r
                              Ehc->DebugPortBarNum,\r
-                             (UINT64) (Ehc->DebugPortOffset + Offset),\r
+                             Ehc->DebugPortOffset + Offset,\r
                              1,\r
                              &Data\r
                              );\r
@@ -115,7 +115,7 @@ EhcReadOpReg (
                              Ehc->PciIo,\r
                              EfiPciIoWidthUint32,\r
                              EHC_BAR_INDEX,\r
-                             (UINT64) (Ehc->CapLen + Offset),\r
+                             Ehc->CapLen + Offset,\r
                              1,\r
                              &Data\r
                              );\r
@@ -152,7 +152,7 @@ EhcWriteOpReg (
                              Ehc->PciIo,\r
                              EfiPciIoWidthUint32,\r
                              EHC_BAR_INDEX,\r
-                             (UINT64) (Ehc->CapLen + Offset),\r
+                             Ehc->CapLen + Offset,\r
                              1,\r
                              &Data\r
                              );\r
index be1b82920003c6a4f91fb7aad87c8c6732b7d823..b1ab34d5974335fe8d29edfc3f1dd183724a70f8 100644 (file)
@@ -5,7 +5,7 @@ ATA controllers in the platform.
 This PPI can be consumed by PEIM which produce gEfiPeiDeviceRecoveryModulePpiGuid\r
 for Atapi CD ROM device.\r
 \r
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 \r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions\r
@@ -593,7 +593,7 @@ AtapiEnumerateDevices (
       //\r
       // Pata & Sata, Primary & Secondary channel, Master & Slave device\r
       //\r
-      DevicePosition = (UINTN) (Index1 * 2 + Index2);\r
+      DevicePosition = Index1 * 2 + Index2;\r
 \r
       if (DiscoverAtapiDevice (AtapiBlkIoDev, DevicePosition, &MediaInfo, &MediaInfo2)) {\r
         //\r
index d2ad94eceb3a11347995b4d2dbe9cd620c218b0d..3713c07844bd26a1a3cb8de62f2740e221c13f52 100644 (file)
@@ -305,7 +305,7 @@ GetOpRomInfo (
     return EFI_NOT_FOUND;\r
   }\r
 \r
-  PciIoDevice->RomSize = (UINT64) ((~AllOnes) + 1);\r
+  PciIoDevice->RomSize = (~AllOnes) + 1;\r
   return EFI_SUCCESS;\r
 }\r
 \r
index 0e1c86cc16f4b7f2464b3e2e69bc44842c353713..4d5937de538f8b907c44ec5ecf1a002a44ef3cfc 100644 (file)
@@ -2,7 +2,7 @@
 \r
   The XHCI register operation routines.\r
 \r
-Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -112,7 +112,7 @@ XhcReadOpReg (
                              Xhc->PciIo,\r
                              EfiPciIoWidthUint32,\r
                              XHC_BAR_INDEX,\r
-                             (UINT64) (Xhc->CapLength + Offset),\r
+                             Xhc->CapLength + Offset,\r
                              1,\r
                              &Data\r
                              );\r
@@ -148,7 +148,7 @@ XhcWriteOpReg (
                              Xhc->PciIo,\r
                              EfiPciIoWidthUint32,\r
                              XHC_BAR_INDEX,\r
-                             (UINT64) (Xhc->CapLength + Offset),\r
+                             Xhc->CapLength + Offset,\r
                              1,\r
                              &Data\r
                              );\r
@@ -181,7 +181,7 @@ XhcWriteOpReg16 (
                              Xhc->PciIo,\r
                              EfiPciIoWidthUint16,\r
                              XHC_BAR_INDEX,\r
-                             (UINT64) (Xhc->CapLength + Offset),\r
+                             Xhc->CapLength + Offset,\r
                              1,\r
                              &Data\r
                              );\r
@@ -215,7 +215,7 @@ XhcReadDoorBellReg (
                              Xhc->PciIo,\r
                              EfiPciIoWidthUint32,\r
                              XHC_BAR_INDEX,\r
-                             (UINT64) (Xhc->DBOff + Offset),\r
+                             Xhc->DBOff + Offset,\r
                              1,\r
                              &Data\r
                              );\r
@@ -251,7 +251,7 @@ XhcWriteDoorBellReg (
                              Xhc->PciIo,\r
                              EfiPciIoWidthUint32,\r
                              XHC_BAR_INDEX,\r
-                             (UINT64) (Xhc->DBOff + Offset),\r
+                             Xhc->DBOff + Offset,\r
                              1,\r
                              &Data\r
                              );\r
@@ -285,7 +285,7 @@ XhcReadRuntimeReg (
                              Xhc->PciIo,\r
                              EfiPciIoWidthUint32,\r
                              XHC_BAR_INDEX,\r
-                             (UINT64) (Xhc->RTSOff + Offset),\r
+                             Xhc->RTSOff + Offset,\r
                              1,\r
                              &Data\r
                              );\r
@@ -321,7 +321,7 @@ XhcWriteRuntimeReg (
                              Xhc->PciIo,\r
                              EfiPciIoWidthUint32,\r
                              XHC_BAR_INDEX,\r
-                             (UINT64) (Xhc->RTSOff + Offset),\r
+                             Xhc->RTSOff + Offset,\r
                              1,\r
                              &Data\r
                              );\r
@@ -355,7 +355,7 @@ XhcReadExtCapReg (
                              Xhc->PciIo,\r
                              EfiPciIoWidthUint32,\r
                              XHC_BAR_INDEX,\r
-                             (UINT64) (Xhc->ExtCapRegBase + Offset),\r
+                             Xhc->ExtCapRegBase + Offset,\r
                              1,\r
                              &Data\r
                              );\r
@@ -391,7 +391,7 @@ XhcWriteExtCapReg (
                              Xhc->PciIo,\r
                              EfiPciIoWidthUint32,\r
                              XHC_BAR_INDEX,\r
-                             (UINT64) (Xhc->ExtCapRegBase + Offset),\r
+                             Xhc->ExtCapRegBase + Offset,\r
                              1,\r
                              &Data\r
                              );\r
index 332ce7e9675ac1902bc4a14f8ce9f63c8d0cad95..1ef6c8878bf9875e5f882f91d06cbe1835b0945d 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-  Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -589,9 +589,9 @@ UfsCreateDMCommandDesc (
   Trd->UcdBaU = (UINT32)RShiftU64 ((UINT64)(UINTN)QueryReqUpiu, 32);\r
   if (Opcode == UtpQueryFuncOpcodeWrDesc) {\r
     Trd->RuL  = (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_RESP_UPIU)), sizeof (UINT32));\r
-    Trd->RuO  = (UINT16)DivU64x32 ((UINT64)(ROUNDUP8 (sizeof (UTP_QUERY_REQ_UPIU)) + ROUNDUP8 (DataSize)), sizeof (UINT32));\r
+    Trd->RuO  = (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_REQ_UPIU)) + ROUNDUP8 (DataSize), sizeof (UINT32));\r
   } else {\r
-    Trd->RuL  = (UINT16)DivU64x32 ((UINT64)(ROUNDUP8 (sizeof (UTP_QUERY_RESP_UPIU)) + ROUNDUP8 (DataSize)), sizeof (UINT32));\r
+    Trd->RuL  = (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_RESP_UPIU)) + ROUNDUP8 (DataSize), sizeof (UINT32));\r
     Trd->RuO  = (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_REQ_UPIU)), sizeof (UINT32));\r
   }\r
 \r
index bc39cf885abe7335350e65261090ceb73a345787..3dd8cbfe7a76e7f2f346bf76c9d1781f66fa4350 100644 (file)
@@ -2,7 +2,7 @@
   UfsPassThruDxe driver is used to produce EFI_EXT_SCSI_PASS_THRU protocol interface\r
   for upper layer application to execute UFS-supported SCSI cmds.\r
 \r
-  Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -666,9 +666,9 @@ UfsCreateDMCommandDesc (
   Trd->UcdBaU = (UINT32)RShiftU64 ((UINT64)CmdDescPhyAddr, 32);\r
   if (Opcode == UtpQueryFuncOpcodeWrDesc) {\r
     Trd->RuL  = (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_RESP_UPIU)), sizeof (UINT32));\r
-    Trd->RuO  = (UINT16)DivU64x32 ((UINT64)(ROUNDUP8 (sizeof (UTP_QUERY_REQ_UPIU)) + ROUNDUP8 (DataSize)), sizeof (UINT32));\r
+    Trd->RuO  = (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_REQ_UPIU)) + ROUNDUP8 (DataSize), sizeof (UINT32));\r
   } else {\r
-    Trd->RuL  = (UINT16)DivU64x32 ((UINT64)(ROUNDUP8 (sizeof (UTP_QUERY_RESP_UPIU)) + ROUNDUP8 (DataSize)), sizeof (UINT32));\r
+    Trd->RuL  = (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_RESP_UPIU)) + ROUNDUP8 (DataSize), sizeof (UINT32));\r
     Trd->RuO  = (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_REQ_UPIU)), sizeof (UINT32));\r
   }\r
 \r
index 652da8bf1075031986192eac214ba2316724ee3e..80128e729b43112548acd57793de12327c529800 100644 (file)
@@ -313,8 +313,8 @@ CheckAndMarkFixLoadingMemoryUsageBitMap (
    //\r
    // Test if the memory is avalaible or not.\r
    // \r
-   BaseOffsetPageNumber = (UINTN)EFI_SIZE_TO_PAGES((UINT32)(ImageBase - DxeCodeBase));\r
-   TopOffsetPageNumber  = (UINTN)EFI_SIZE_TO_PAGES((UINT32)(ImageBase + ImageSize - DxeCodeBase));\r
+   BaseOffsetPageNumber = EFI_SIZE_TO_PAGES((UINT32)(ImageBase - DxeCodeBase));\r
+   TopOffsetPageNumber  = EFI_SIZE_TO_PAGES((UINT32)(ImageBase + ImageSize - DxeCodeBase));\r
    for (Index = BaseOffsetPageNumber; Index < TopOffsetPageNumber; Index ++) {\r
      if ((mDxeCodeMemoryRangeUsageBitMap[Index / 64] & LShiftU64(1, (Index % 64))) != 0) {\r
        //\r
@@ -366,12 +366,10 @@ GetPeCoffImageFixLoadingAssignedAddress(
    //\r
    Handle = (IMAGE_FILE_HANDLE*)ImageContext->Handle;\r
    ImgHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((CHAR8* )Handle->Source + ImageContext->PeCoffHeaderOffset);\r
-   SectionHeaderOffset = (UINTN)(\r
-                                 ImageContext->PeCoffHeaderOffset +\r
-                                 sizeof (UINT32) +\r
-                                 sizeof (EFI_IMAGE_FILE_HEADER) +\r
-                                 ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader\r
-                                 );\r
+   SectionHeaderOffset = ImageContext->PeCoffHeaderOffset +\r
+                         sizeof (UINT32) +\r
+                         sizeof (EFI_IMAGE_FILE_HEADER) +\r
+                         ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader;\r
    NumberOfSections = ImgHdr->Pe32.FileHeader.NumberOfSections;\r
 \r
    //\r
index 47660729ba79fff8906e413d81ab5a3d47ccbcbf..fda6d44043d3e044701f224ff5943b2643359e12 100644 (file)
@@ -2,7 +2,7 @@
   Support functions for managing debug image info table when loading and unloading\r
   images.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -103,7 +103,7 @@ CoreInitializeDebugImageInfoTable (
     Status = CoreFreePages (Memory, UnalignedPages);\r
     ASSERT_EFI_ERROR (Status);\r
   }\r
-  Memory         = (EFI_PHYSICAL_ADDRESS)(AlignedMemory + EFI_PAGES_TO_SIZE (Pages));\r
+  Memory         = AlignedMemory + EFI_PAGES_TO_SIZE (Pages);\r
   UnalignedPages = RealPages - Pages - UnalignedPages;\r
   if (UnalignedPages > 0) {\r
     //\r
index 68e40c027e63a1faf60c4de21e4fe16ecebeef2e..c8bb2300a0a6681a7c58dca85fb2f1d8f22b343c 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Pei Core Load Image Support\r
 \r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -251,12 +251,10 @@ GetPeCoffImageFixLoadingAssignedAddress(
      SectionHeaderOffset = sizeof (EFI_TE_IMAGE_HEADER);\r
      NumberOfSections = ImgHdr->Te.NumberOfSections;\r
    } else {\r
-     SectionHeaderOffset = (UINTN)(\r
-                                 ImageContext->PeCoffHeaderOffset +\r
-                                 sizeof (UINT32) +\r
-                                 sizeof (EFI_IMAGE_FILE_HEADER) +\r
-                                 ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader\r
-                                 );\r
+     SectionHeaderOffset = ImageContext->PeCoffHeaderOffset +\r
+                           sizeof (UINT32) +\r
+                           sizeof (EFI_IMAGE_FILE_HEADER) +\r
+                           ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader;\r
       NumberOfSections = ImgHdr->Pe32.FileHeader.NumberOfSections;\r
    }\r
    //\r
index 1bddaf13ae7cb0e4e7b0edd34bfa14e1f955466f..b2a68220489e4621a0173fea21eff80aa52ab66a 100644 (file)
@@ -28,7 +28,7 @@
   Depex - Dependency Expresion.\r
 \r
   Copyright (c) 2014, Hewlett-Packard Development Company, L.P.\r
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials are licensed and made available \r
   under the terms and conditions of the BSD License which accompanies this \r
   distribution.  The full text of the license may be found at        \r
@@ -183,8 +183,8 @@ CheckAndMarkFixLoadingMemoryUsageBitMap (
    //\r
    // Test if the memory is avalaible or not.\r
    // \r
-   BaseOffsetPageNumber = (UINTN)EFI_SIZE_TO_PAGES((UINT32)(ImageBase - SmmCodeBase));\r
-   TopOffsetPageNumber  = (UINTN)EFI_SIZE_TO_PAGES((UINT32)(ImageBase + ImageSize - SmmCodeBase));\r
+   BaseOffsetPageNumber = EFI_SIZE_TO_PAGES((UINT32)(ImageBase - SmmCodeBase));\r
+   TopOffsetPageNumber  = EFI_SIZE_TO_PAGES((UINT32)(ImageBase + ImageSize - SmmCodeBase));\r
    for (Index = BaseOffsetPageNumber; Index < TopOffsetPageNumber; Index ++) {\r
      if ((mSmmCodeMemoryRangeUsageBitMap[Index / 64] & LShiftU64(1, (Index % 64))) != 0) {\r
        //\r
@@ -234,12 +234,10 @@ GetPeCoffImageFixLoadingAssignedAddress(
   // Get PeHeader pointer\r
   //\r
   ImgHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((CHAR8* )ImageContext->Handle + ImageContext->PeCoffHeaderOffset);\r
-  SectionHeaderOffset = (UINTN)(\r
-                                 ImageContext->PeCoffHeaderOffset +\r
-                                 sizeof (UINT32) +\r
-                                 sizeof (EFI_IMAGE_FILE_HEADER) +\r
-                                 ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader\r
-                                 );\r
+  SectionHeaderOffset = ImageContext->PeCoffHeaderOffset +\r
+                        sizeof (UINT32) +\r
+                        sizeof (EFI_IMAGE_FILE_HEADER) +\r
+                        ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader;\r
   NumberOfSections = ImgHdr->Pe32.FileHeader.NumberOfSections;\r
 \r
   //\r
@@ -520,7 +518,7 @@ SmmLoadImage (
   // Align buffer on section boundary\r
   //\r
   ImageContext.ImageAddress += ImageContext.SectionAlignment - 1;\r
-  ImageContext.ImageAddress &= ~((EFI_PHYSICAL_ADDRESS)(ImageContext.SectionAlignment - 1));\r
+  ImageContext.ImageAddress &= ~((EFI_PHYSICAL_ADDRESS)ImageContext.SectionAlignment - 1);\r
 \r
   //\r
   // Load the image to our new buffer\r
index 26b71f163a9aa05712db14fee8f668553294465e..feb846ee9e0ef49dc92dd22b4d55bbe6d9f5550d 100644 (file)
@@ -846,12 +846,10 @@ GetPeCoffImageFixLoadingAssignedAddress(
    // Get PeHeader pointer\r
    //\r
    ImgHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((CHAR8* )ImageContext->Handle + ImageContext->PeCoffHeaderOffset);\r
-   SectionHeaderOffset = (UINTN)(\r
-                                 ImageContext->PeCoffHeaderOffset +\r
-                                 sizeof (UINT32) +\r
-                                 sizeof (EFI_IMAGE_FILE_HEADER) +\r
-                                 ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader\r
-                                 );\r
+   SectionHeaderOffset = ImageContext->PeCoffHeaderOffset +\r
+                         sizeof (UINT32) +\r
+                         sizeof (EFI_IMAGE_FILE_HEADER) +\r
+                         ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader;\r
    NumberOfSections = ImgHdr->Pe32.FileHeader.NumberOfSections;\r
 \r
    //\r
@@ -1022,7 +1020,7 @@ ExecuteSmmCoreFromSmram (
   }\r
   \r
   ImageContext.ImageAddress += ImageContext.SectionAlignment - 1;\r
-  ImageContext.ImageAddress &= ~((EFI_PHYSICAL_ADDRESS)(ImageContext.SectionAlignment - 1));\r
+  ImageContext.ImageAddress &= ~((EFI_PHYSICAL_ADDRESS)ImageContext.SectionAlignment - 1);\r
 \r
   //\r
   // Print debug message showing SMM Core load address.\r
index d7abcc879b5abdba7a520efc8f705ae90b38c7ad..7f500a96ebe38f945166e6faafe4f4050bd001c3 100644 (file)
@@ -585,7 +585,7 @@ DisplayCapsuleImage (
   EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;\r
 \r
   ImagePayload = (DISPLAY_DISPLAY_PAYLOAD *)(CapsuleHeader + 1);\r
-  PayloadSize = (UINTN)(CapsuleHeader->CapsuleImageSize - sizeof(EFI_CAPSULE_HEADER));\r
+  PayloadSize = CapsuleHeader->CapsuleImageSize - sizeof(EFI_CAPSULE_HEADER);\r
 \r
   if (ImagePayload->Version != 1) {\r
     return EFI_UNSUPPORTED;\r
@@ -733,7 +733,7 @@ DumpFmpCapsule (
   for (Index = 0; Index < FmpCapsuleHeader->EmbeddedDriverCount; Index++) {\r
     DEBUG((DEBUG_VERBOSE, "  ItemOffsetList[%d]      - 0x%lx\n", Index, ItemOffsetList[Index]));\r
   }\r
-  for (; Index < (UINTN)(FmpCapsuleHeader->EmbeddedDriverCount + FmpCapsuleHeader->PayloadItemCount); Index++) {\r
+  for (; Index < (UINT32)FmpCapsuleHeader->EmbeddedDriverCount + FmpCapsuleHeader->PayloadItemCount; Index++) {\r
     DEBUG((DEBUG_VERBOSE, "  ItemOffsetList[%d]      - 0x%lx\n", Index, ItemOffsetList[Index]));\r
     ImageHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index]);\r
 \r
index 89c19e7c83dcb6ad0922dac813f15ff454169ea5..95725c866f13a67033460b556554a9dde9b44bf8 100644 (file)
@@ -3,7 +3,7 @@
   on DxeCore Memory Allocation services for DxeCore,\r
   with memory profile support.\r
 \r
-  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials                          \r
   are licensed and made available under the terms and conditions of the BSD License         \r
   which accompanies this distribution.  The full text of the license may be found at        \r
@@ -258,7 +258,7 @@ InternalAllocateAlignedPages (
       Status = CoreFreePages (Memory, UnalignedPages);\r
       ASSERT_EFI_ERROR (Status);\r
     }\r
-    Memory         = (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages));\r
+    Memory         = AlignedMemory + EFI_PAGES_TO_SIZE (Pages);\r
     UnalignedPages = RealPages - Pages - UnalignedPages;\r
     if (UnalignedPages > 0) {\r
       //\r
index 6066526abee509a07cbf7014d5e698546d3f4162..7cd7e3aca007282871348d9819ff1837b86a741d 100644 (file)
@@ -2995,7 +2995,7 @@ NetLibGetSystemGuid (
       return EFI_NOT_FOUND;\r
     }\r
     Smbios.Hdr    = (SMBIOS_STRUCTURE *) (UINTN) SmbiosTable->TableAddress;\r
-    SmbiosEnd.Raw = (UINT8 *) (UINTN) (SmbiosTable->TableAddress + SmbiosTable->TableLength);\r
+    SmbiosEnd.Raw = (UINT8 *) ((UINTN) SmbiosTable->TableAddress + SmbiosTable->TableLength);\r
   }\r
 \r
   do {\r
index 1f8aaf47c8753b8651c691ecd0934642c0aecd1e..fe2d3a0284080ee93e26f5314dadcefe46e11dfd 100644 (file)
@@ -691,7 +691,7 @@ S3BootScriptGetBootTimeEntryAddAddress (
    // Here we do not count the reserved memory for runtime script table.\r
    PageNumber = (UINT16) (mS3BootScriptTablePtr->TableMemoryPageNumber - PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber));\r
    TableLength =  mS3BootScriptTablePtr->TableLength;\r
-   if ((UINTN) EFI_PAGES_TO_SIZE ((UINTN) PageNumber) < (UINTN) (TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE))) {\r
+   if (EFI_PAGES_TO_SIZE ((UINTN) PageNumber) < (TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE))) {\r
      //\r
      // The buffer is too small to hold the table, Reallocate the buffer\r
      //\r
@@ -752,7 +752,7 @@ S3BootScriptGetRuntimeEntryAddAddress (
    //\r
    // Check if the memory range reserved for S3 Boot Script table is large enough to hold the node.\r
    //\r
-   if ((UINTN) (mS3BootScriptTablePtr->TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE)) <= (UINTN) EFI_PAGES_TO_SIZE ((UINTN) (mS3BootScriptTablePtr->TableMemoryPageNumber))) {\r
+   if ((mS3BootScriptTablePtr->TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE)) <= EFI_PAGES_TO_SIZE ((UINTN) (mS3BootScriptTablePtr->TableMemoryPageNumber))) {\r
      NewEntryPtr = mS3BootScriptTablePtr->TableBase + mS3BootScriptTablePtr->TableLength;\r
      mS3BootScriptTablePtr->TableLength = mS3BootScriptTablePtr->TableLength + EntryLength;\r
      //\r
index bd2146892495656a8b179d1969e4522644852c26..96cb275cc9d7206474b5545ddd8bb3cc4d840654 100644 (file)
@@ -11,7 +11,7 @@
   In addition, allocation for the Reserved memory types are not supported and will \r
   always return NULL.\r
 \r
-  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials                          \r
   are licensed and made available under the terms and conditions of the BSD License         \r
   which accompanies this distribution.  The full text of the license may be found at        \r
@@ -293,7 +293,7 @@ InternalAllocateAlignedPages (
       Status = SmmFreePages (Memory, UnalignedPages);\r
       ASSERT_EFI_ERROR (Status);\r
     }\r
-    Memory         = (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages));\r
+    Memory         = AlignedMemory + EFI_PAGES_TO_SIZE (Pages);\r
     UnalignedPages = RealPages - Pages - UnalignedPages;\r
     if (UnalignedPages > 0) {\r
       //\r
index e9bbf02311bdd27ddad9d8eead8858e6a532ffdc..2a18155e56060cf9fa116ae7410c5b62fb0a77b2 100644 (file)
@@ -12,7 +12,7 @@
   allocation for the Reserved memory types are not supported and will always \r
   return NULL.\r
 \r
-  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials                          \r
   are licensed and made available under the terms and conditions of the BSD License         \r
   which accompanies this distribution.  The full text of the license may be found at        \r
@@ -371,7 +371,7 @@ InternalAllocateAlignedPages (
       Status = gSmst->SmmFreePages (Memory, UnalignedPages);\r
       ASSERT_EFI_ERROR (Status);\r
     }\r
-    Memory         = (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages));\r
+    Memory         = AlignedMemory + EFI_PAGES_TO_SIZE (Pages);\r
     UnalignedPages = RealPages - Pages - UnalignedPages;\r
     if (UnalignedPages > 0) {\r
       //\r
index e11d8428d63b4466bd297710e13e7be615f796cd..11ab86792a52534120070a4541d784838375fc7d 100644 (file)
@@ -413,11 +413,11 @@ BmCharToUint (
   )\r
 {\r
   if ((Char >= L'0') && (Char <= L'9')) {\r
-    return (UINTN) (Char - L'0');\r
+    return (Char - L'0');\r
   }\r
 \r
   if ((Char >= L'A') && (Char <= L'F')) {\r
-    return (UINTN) (Char - L'A' + 0xA);\r
+    return (Char - L'A' + 0xA);\r
   }\r
 \r
   ASSERT (FALSE);\r
index b740d43aad4b387ee507047f62f2de326b319598..a2abf26980b9ddaec07cdced210fbe68dd3b93b0 100644 (file)
@@ -1874,7 +1874,7 @@ GetBlockDataInfo (
     //\r
     // Check whether VarBuffer is enough\r
     //\r
-    if ((UINTN) (Offset + Width) > MaxBufferSize) {\r
+    if ((UINT32)Offset + Width > MaxBufferSize) {\r
       DataBuffer = ReallocatePool (\r
                     MaxBufferSize,\r
                     Offset + Width + HII_LIB_DEFAULT_VARSTORE_SIZE,\r
index 370827ddde33241491529a60615b745f926bdc85..cef7fc0c05d4f8b1fc3a629ff6f0bf4f5ebc5c5f 100644 (file)
@@ -2,7 +2,7 @@
   Support routines for memory allocation routines based \r
   on boot services for Dxe phase drivers, with memory profile support.\r
 \r
-  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials                          \r
   are licensed and made available under the terms and conditions of the BSD License         \r
   which accompanies this distribution.  The full text of the license may be found at        \r
@@ -257,7 +257,7 @@ InternalAllocateAlignedPages (
       Status = gBS->FreePages (Memory, UnalignedPages);\r
       ASSERT_EFI_ERROR (Status);\r
     }\r
-    Memory         = (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages));\r
+    Memory         = AlignedMemory + EFI_PAGES_TO_SIZE (Pages);\r
     UnalignedPages = RealPages - Pages - UnalignedPages;\r
     if (UnalignedPages > 0) {\r
       //\r
index b9ca9084915b220ef84072db9f897f2d2adc0c2c..93ff9340e90c86f68284826f66ece4909cf96bf0 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Var Check Hii handler.\r
 \r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -94,7 +94,7 @@ VarCheckHiiQuestion (
   UINT8    Index;\r
   UINT8    MaxContainers;\r
 \r
-  if ((UINTN) (HiiQuestion->VarOffset + HiiQuestion->StorageWidth) > DataSize) {\r
+  if (((UINT32) HiiQuestion->VarOffset + HiiQuestion->StorageWidth) > DataSize) {\r
     DEBUG ((EFI_D_INFO, "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->StorageWidth, DataSize));\r
     return FALSE;\r
   }\r
@@ -155,7 +155,7 @@ VarCheckHiiQuestion (
 \r
     case EFI_IFR_ORDERED_LIST_OP:\r
       MaxContainers = ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion)->MaxContainers;\r
-      if ((UINTN) (HiiQuestion->VarOffset + HiiQuestion->StorageWidth * MaxContainers) > DataSize) {\r
+      if (((UINT32) HiiQuestion->VarOffset + HiiQuestion->StorageWidth * MaxContainers) > DataSize) {\r
         DEBUG ((EFI_D_INFO, "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x) * MaxContainers(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->StorageWidth, MaxContainers, DataSize));\r
         return FALSE;\r
       }\r
index 22d434914befa9c96700791af381fda4276ee1d2..5147e66b4ee6018f0bf40a90578b4e5bb174f80c 100644 (file)
@@ -4,7 +4,7 @@
   This driver is dispatched by Dxe core and the driver will reload itself to ACPI reserved memory\r
   in the entry point. The functionality is to interpret and restore the S3 boot script\r
 \r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>\r
 \r
 This program and the accompanying materials\r
@@ -327,7 +327,7 @@ ReadyToLockEventNotify (
   // Align buffer on section boundary\r
   //\r
   ImageContext.ImageAddress += ImageContext.SectionAlignment - 1;\r
-  ImageContext.ImageAddress &= ~((EFI_PHYSICAL_ADDRESS)(ImageContext.SectionAlignment - 1));\r
+  ImageContext.ImageAddress &= ~((EFI_PHYSICAL_ADDRESS)ImageContext.SectionAlignment - 1);\r
   //\r
   // Load the image to our new buffer\r
   //\r
index a973d2db059a73a68399de2a8e9f0e0844fbb08d..dcfd61c9baee0338078042d3b2a6f7a1d2416346 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   This is the implementation to save ACPI S3 Context.\r
 \r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 \r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions\r
@@ -401,9 +401,9 @@ S3AllocatePageTablesBuffer (
     // We need calculate whole page size then allocate once, because S3 restore page table does not know each page in Nvs.\r
     //\r
     if (!Page1GSupport) {\r
-      TotalPageTableSize = (UINTN)(1 + NumberOfPml4EntriesNeeded + NumberOfPml4EntriesNeeded * NumberOfPdpEntriesNeeded);\r
+      TotalPageTableSize = 1 + NumberOfPml4EntriesNeeded + NumberOfPml4EntriesNeeded * NumberOfPdpEntriesNeeded;\r
     } else {\r
-      TotalPageTableSize = (UINTN)(1 + NumberOfPml4EntriesNeeded);\r
+      TotalPageTableSize = 1 + NumberOfPml4EntriesNeeded;\r
     }\r
 \r
     TotalPageTableSize += ExtraPageTablePages;\r
index 9e8315eb97c62c7d87aca443424f8eb097c9855f..3e7054cd38a9516bbeb89f7221494b98351d81ae 100644 (file)
@@ -10,7 +10,7 @@
   into memory.\r
 \r
 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
-Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -1247,7 +1247,7 @@ CapsuleDataCoalesce (
         //\r
         ASSERT (PrivateDataPtr->Signature == EFI_CAPSULE_PEIM_PRIVATE_DATA_SIGNATURE);\r
         ASSERT ((UINTN)DestPtr >= (UINTN)CapsuleImageBase);\r
-        PrivateDataPtr->CapsuleOffset[CapsuleIndex++] = (UINT64)((UINTN)DestPtr - (UINTN)CapsuleImageBase);\r
+        PrivateDataPtr->CapsuleOffset[CapsuleIndex++] = (UINTN)DestPtr - (UINTN)CapsuleImageBase;\r
       }\r
 \r
       //\r
index 0eb7dddf7baad2cb7e416fa2e25c1c8ee956593f..e1ac5a32233f93ea530004b1f9d3eb424da15817 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Entry and initialization module for the browser.\r
 \r
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
 Copyright (c) 2014, Hewlett-Packard Development Company, L.P.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -540,7 +540,7 @@ GetLineByWidth (
   //\r
   // Need extra glyph info and '\0' info, so +2.\r
   //\r
-  *OutputString = AllocateZeroPool (((UINTN) (StrOffset + 2) * sizeof(CHAR16)));\r
+  *OutputString = AllocateZeroPool ((StrOffset + 2) * sizeof(CHAR16));\r
   if (*OutputString == NULL) {\r
     return 0;\r
   }\r
@@ -2972,7 +2972,7 @@ UiDisplayMenu (
         gST->ConOut->SetAttribute (gST->ConOut, GetInfoTextColor ());\r
         for (Index = 0; Index < HelpHeaderLine; Index++) {\r
           ASSERT (HelpHeaderLine == 1);\r
-          ASSERT (GetStringWidth (HelpHeaderString) / 2 < (UINTN) (gHelpBlockWidth - 1));\r
+          ASSERT (GetStringWidth (HelpHeaderString) / 2 < ((UINT32) gHelpBlockWidth - 1));\r
           PrintStringAtWithWidth (\r
             gStatementDimensions.RightColumn - gHelpBlockWidth,\r
             Index + TopRow,\r
@@ -3053,7 +3053,7 @@ UiDisplayMenu (
         gST->ConOut->SetAttribute (gST->ConOut, GetInfoTextColor ());\r
         for (Index = 0; Index < HelpBottomLine; Index++) {\r
           ASSERT (HelpBottomLine == 1);\r
-          ASSERT (GetStringWidth (HelpBottomString) / 2 < (UINTN) (gHelpBlockWidth - 1)); \r
+          ASSERT (GetStringWidth (HelpBottomString) / 2 < ((UINT32) gHelpBlockWidth - 1));\r
           PrintStringAtWithWidth (\r
             gStatementDimensions.RightColumn - gHelpBlockWidth,\r
             BottomRow + Index - HelpBottomLine + 1,\r
index e5d290a2fec6a15be0eec78ca3d34ca94dab4e40..2dfed8ecf54fcebf1ff9782cef21ae192c7b173c 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Contains code that implements the virtual machine.\r
 \r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -2867,7 +2867,7 @@ ExecutePOPn (
   if (OPERAND1_INDIRECT (Operands)) {\r
     VmWriteMemN (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16), DataN);\r
   } else {\r
-    VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (INT64) (UINT64) ((UINTN) DataN + Index16);\r
+    VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (INT64) (UINT64) (UINTN) (DataN + Index16);\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -3592,7 +3592,7 @@ ExecuteSUB (
   if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {\r
     return (UINT64) ((INT64) ((INT64) Op1 - (INT64) Op2));\r
   } else {\r
-    return (UINT64) ((INT64) ((INT32) Op1 - (INT32) Op2));\r
+    return (UINT64) ((INT64) ((INT32) ((INT32) Op1 - (INT32) Op2)));\r
   }\r
 }\r
 \r
@@ -3620,7 +3620,7 @@ ExecuteMUL (
   if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {\r
     return MultS64x64 ((INT64)Op1, (INT64)Op2);\r
   } else {\r
-    return (UINT64) ((INT64) ((INT32) Op1 * (INT32) Op2));\r
+    return (UINT64) ((INT64) ((INT32) ((INT32) Op1 * (INT32) Op2)));\r
   }\r
 }\r
 \r
@@ -3648,7 +3648,7 @@ ExecuteMULU (
   if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {\r
     return MultU64x64 (Op1, Op2);\r
   } else {\r
-    return (UINT64) ((UINT32) Op1 * (UINT32) Op2);\r
+    return (UINT64) ((UINT32) ((UINT32) Op1 * (UINT32) Op2));\r
   }\r
 }\r
 \r
index d46a37fde3f4e56ec3a78d24a5b0d78649195e25..b4327b56192124252096cd2397c653db70742df2 100644 (file)
@@ -2,7 +2,7 @@
 \r
    Internal functions to operate Working Block Space.\r
 \r
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -55,7 +55,7 @@ InitializeLocalWorkSpaceHeader (
     &gEdkiiWorkingBlockSignatureGuid,\r
     sizeof (EFI_GUID)\r
     );\r
-  mWorkingBlockHeader.WriteQueueSize = (UINT64) (PcdGet32 (PcdFlashNvStorageFtwWorkingSize) - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER));\r
+  mWorkingBlockHeader.WriteQueueSize = PcdGet32 (PcdFlashNvStorageFtwWorkingSize) - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER);\r
 \r
   //\r
   // Crc is calculated with all the fields except Crc and STATE, so leave them as FTW_ERASED_BYTE.\r
index 9bef0642af6c0935e421551826f2c54edb3e8810..b85cf88f54e53a8386ad1ed7005f8c09f52df9cb 100644 (file)
@@ -2,7 +2,7 @@
 Implementation for EFI_HII_FONT_PROTOCOL.\r
 \r
 \r
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -411,7 +411,7 @@ GlyphToBlt (
   // The glyph's upper left hand corner pixel is the most significant bit of the\r
   // first bitmap byte.\r
   //\r
-  for (Ypos = 0; Ypos < Cell->Height && ((UINTN) (Ypos + YposOffset) < RowHeight); Ypos++) {\r
+  for (Ypos = 0; Ypos < Cell->Height && (((UINT32) Ypos + YposOffset) < RowHeight); Ypos++) {\r
     OffsetY = BITMAP_LEN_1_BIT (Cell->Width, Ypos);\r
 \r
     //\r
@@ -419,7 +419,7 @@ GlyphToBlt (
     //\r
     for (Xpos = 0; Xpos < Cell->Width / 8; Xpos++) {\r
       Data  = *(GlyphBuffer + OffsetY + Xpos);\r
-      for (Index = 0; Index < 8 && ((UINTN) (Xpos * 8 + Index + Cell->OffsetX) < RowWidth); Index++) {\r
+      for (Index = 0; Index < 8 && (((UINT32) Xpos * 8 + Index + Cell->OffsetX) < RowWidth); Index++) {\r
         if ((Data & (1 << (8 - Index - 1))) != 0) {\r
           BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Foreground;\r
         } else {\r
@@ -435,7 +435,7 @@ GlyphToBlt (
       // There are some padding bits in this byte. Ignore them.\r
       //\r
       Data  = *(GlyphBuffer + OffsetY + Xpos);\r
-      for (Index = 0; Index < Cell->Width % 8 && ((UINTN) (Xpos * 8 + Index + Cell->OffsetX) < RowWidth); Index++) {\r
+      for (Index = 0; Index < Cell->Width % 8 && (((UINT32) Xpos * 8 + Index + Cell->OffsetX) < RowWidth); Index++) {\r
         if ((Data & (1 << (8 - Index - 1))) != 0) {\r
           BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Foreground;\r
         } else {\r
@@ -1927,7 +1927,7 @@ HiiStringToImage (
     // If this character is the last character of a row, we need not\r
     // draw its (AdvanceX - Width - OffsetX) for next character.\r
     //\r
-    LineWidth -= (UINTN) (Cell[Index].AdvanceX - Cell[Index].Width - Cell[Index].OffsetX);\r
+    LineWidth -= (Cell[Index].AdvanceX - Cell[Index].Width - Cell[Index].OffsetX);\r
 \r
     //\r
     // Clip the right-most character if cannot fit when EFI_HII_OUT_FLAG_CLEAN_X is set.\r
@@ -1950,8 +1950,8 @@ HiiStringToImage (
         //\r
         // Don't draw the last char on this row. And, don't draw the second last char (AdvanceX - Width - OffsetX).\r
         //\r
-        LineWidth -= (UINTN) (Cell[Index].Width + Cell[Index].OffsetX);\r
-        LineWidth -= (UINTN) (Cell[Index - 1].AdvanceX - Cell[Index - 1].Width - Cell[Index - 1].OffsetX);\r
+        LineWidth -= (Cell[Index].Width + Cell[Index].OffsetX);\r
+        LineWidth -= (Cell[Index - 1].AdvanceX - Cell[Index - 1].Width - Cell[Index - 1].OffsetX);\r
         RowInfo[RowIndex].EndIndex       = Index - 1;\r
         RowInfo[RowIndex].LineWidth      = LineWidth;\r
         RowInfo[RowIndex].LineHeight     = LineHeight;\r
@@ -2008,7 +2008,7 @@ HiiStringToImage (
           if (Index1 == RowInfo[RowIndex].StartIndex) {\r
             LineWidth = 0;\r
           } else {\r
-            LineWidth -= (UINTN) (Cell[Index1 - 1].AdvanceX - Cell[Index1 - 1].Width - Cell[Index1 - 1].OffsetX);\r
+            LineWidth -= (Cell[Index1 - 1].AdvanceX - Cell[Index1 - 1].Width - Cell[Index1 - 1].OffsetX);\r
           }\r
           RowInfo[RowIndex].LineWidth = LineWidth;\r
         }\r
@@ -2025,8 +2025,8 @@ HiiStringToImage (
             //\r
             // Don't draw the last char on this row. And, don't draw the second last char (AdvanceX - Width - OffsetX).\r
             //\r
-            LineWidth -= (UINTN) (Cell[Index1].Width + Cell[Index1].OffsetX);\r
-            LineWidth -= (UINTN) (Cell[Index1 - 1].AdvanceX - Cell[Index1 - 1].Width - Cell[Index1 - 1].OffsetX);\r
+            LineWidth -= (Cell[Index1].Width + Cell[Index1].OffsetX);\r
+            LineWidth -= (Cell[Index1 - 1].AdvanceX - Cell[Index1 - 1].Width - Cell[Index1 - 1].OffsetX);\r
             RowInfo[RowIndex].EndIndex       = Index1 - 1;\r
             RowInfo[RowIndex].LineWidth      = LineWidth;\r
           } else {\r
index 639da4880f247073ce3391c2676e588f9f6d28cd..cd00f5c52dc35bcfefee1338191e52770b2018dc 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Interface routines for PxeBc.\r
 \r
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -353,8 +353,8 @@ EfiPxeBcStart (
   //\r
   // Configure block size for TFTP as a default value to handle all link layers.\r
   // \r
-  Private->BlockSize   = (UINTN) (MIN (Private->Ip4MaxPacketSize, PXEBC_DEFAULT_PACKET_SIZE) - \r
-                           PXEBC_DEFAULT_UDP_OVERHEAD_SIZE - PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE);\r
+  Private->BlockSize   = MIN (Private->Ip4MaxPacketSize, PXEBC_DEFAULT_PACKET_SIZE) -\r
+                           PXEBC_DEFAULT_UDP_OVERHEAD_SIZE - PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE;\r
   //\r
   // If PcdTftpBlockSize is set to non-zero, override the default value.\r
   //\r
index bf7713017094d902c61d523c685986a57b9562b4..efe72483c5e65be554f7cfb99fb7ee10b1d57ec0 100644 (file)
@@ -2,7 +2,7 @@
     Help functions used by PCD DXE driver.\r
 \r
 Copyright (c) 2014, Hewlett-Packard Development Company, L.P.<BR>\r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -452,7 +452,7 @@ GetWorker (
   switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {\r
     case PCD_TYPE_VPD:\r
       VpdHead = (VPD_HEAD *) ((UINT8 *) PcdDb + Offset);\r
-      RetPtr = (VOID *) (UINTN) (PcdGet32 (PcdVpdBaseAddress) + VpdHead->Offset);\r
+      RetPtr = (VOID *) ((UINTN) PcdGet32 (PcdVpdBaseAddress) + VpdHead->Offset);\r
 \r
       break;\r
 \r
index 66ca892ed2e05b3511d21604206f11f86610e1a5..5e1cb72ba5d5936ced5e393fef8998454391e542 100644 (file)
@@ -2,7 +2,7 @@
   The driver internal functions are implmented here.\r
   They build Pei PCD database, and provide access service to PCD database.\r
 \r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -985,7 +985,7 @@ GetWorker (
     {\r
       VPD_HEAD *VpdHead;\r
       VpdHead = (VPD_HEAD *) ((UINT8 *)PeiPcdDb + Offset);\r
-      return (VOID *) (UINTN) (PcdGet32 (PcdVpdBaseAddress) + VpdHead->Offset);\r
+      return (VOID *) ((UINTN) PcdGet32 (PcdVpdBaseAddress) + VpdHead->Offset);\r
     }\r
       \r
     case PCD_TYPE_HII|PCD_TYPE_STRING:\r
index ea762d59b9bdbefd35cdc54d96754d6555c92afd..4e757e1c47c0e16512c5825c5f24be4e245ca163 100644 (file)
@@ -2,7 +2,7 @@
   This code produces the Smbios protocol. It also responsible for constructing \r
   SMBIOS table into system table.\r
   \r
-Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -1138,7 +1138,7 @@ SmbiosCreateTable (
     EntryPointStructure->MaxStructureSize = (UINT16) sizeof (EndStructure);\r
   }\r
 \r
-  if ((UINTN) EFI_SIZE_TO_PAGES (EntryPointStructure->TableLength) > mPreAllocatedPages) {\r
+  if (EFI_SIZE_TO_PAGES ((UINT32) EntryPointStructure->TableLength) > mPreAllocatedPages) {\r
     //\r
     // If new SMBIOS table size exceeds the previous allocated page, \r
     // it is time to re-allocate memory (below 4GB).\r
@@ -1307,7 +1307,7 @@ SmbiosCreate64BitTable (
   EndStructure.Tailing[1] = 0;\r
   Smbios30EntryPointStructure->TableMaximumSize = (UINT32) (Smbios30EntryPointStructure->TableMaximumSize + sizeof (EndStructure));\r
 \r
-  if ((UINTN) EFI_SIZE_TO_PAGES (Smbios30EntryPointStructure->TableMaximumSize) > mPre64BitAllocatedPages) {\r
+  if (EFI_SIZE_TO_PAGES (Smbios30EntryPointStructure->TableMaximumSize) > mPre64BitAllocatedPages) {\r
     //\r
     // If new SMBIOS table size exceeds the previous allocated page, \r
     // it is time to re-allocate memory at anywhere.\r
index b0c7434baeb1f0fe32de32a24bca99470e47ec8f..0a325de1659d3eaf2d35f193b065212ea697fd80 100644 (file)
@@ -3754,8 +3754,8 @@ InitNonVolatileVariableStore (
     return EFI_VOLUME_CORRUPTED;\r
   }\r
 \r
-  VariableStoreBase = (EFI_PHYSICAL_ADDRESS) ((UINTN) FvHeader + FvHeader->HeaderLength);\r
-  VariableStoreLength = (UINT64) (NvStorageSize - FvHeader->HeaderLength);\r
+  VariableStoreBase = (UINTN) FvHeader + FvHeader->HeaderLength;\r
+  VariableStoreLength = NvStorageSize - FvHeader->HeaderLength;\r
 \r
   mNvFvHeaderCache = FvHeader;\r
   mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase = VariableStoreBase;\r
@@ -4099,7 +4099,7 @@ VariableCommonInitialize (
   GuidHob = GetFirstGuidHob (VariableGuid);\r
   if (GuidHob != NULL) {\r
     VariableStoreHeader = GET_GUID_HOB_DATA (GuidHob);\r
-    VariableStoreLength = (UINT64) (GuidHob->Header.HobLength - sizeof (EFI_HOB_GUID_TYPE));\r
+    VariableStoreLength = GuidHob->Header.HobLength - sizeof (EFI_HOB_GUID_TYPE);\r
     if (GetVariableStoreStatus (VariableStoreHeader) == EfiValid) {\r
       mVariableModuleGlobal->VariableGlobal.HobVariableBase = (EFI_PHYSICAL_ADDRESS) (UINTN) AllocateRuntimeCopyPool ((UINTN) VariableStoreLength, (VOID *) VariableStoreHeader);\r
       if (mVariableModuleGlobal->VariableGlobal.HobVariableBase == 0) {\r