diff options
author | Hao Wu <hao.a.wu@intel.com> | 2017-02-24 10:01:34 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2017-03-06 14:33:20 +0800 |
commit | 16f6922709952c7ad468dcdee6ef94b3e5a3cd90 (patch) | |
tree | 999456e2e6812457d5c0b32b969ac0eed2b02149 /MdeModulePkg/Universal | |
parent | 95ba3d92dca2616715e2af89d2bbeca9577a3e2c (diff) | |
download | edk2-platforms-16f6922709952c7ad468dcdee6ef94b3e5a3cd90.tar.xz |
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 = (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>
Diffstat (limited to 'MdeModulePkg/Universal')
12 files changed, 41 insertions, 41 deletions
diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c index 22d434914b..5147e66b4e 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
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
This program and the accompanying materials
@@ -327,7 +327,7 @@ ReadyToLockEventNotify ( // Align buffer on section boundary
//
ImageContext.ImageAddress += ImageContext.SectionAlignment - 1;
- ImageContext.ImageAddress &= ~((EFI_PHYSICAL_ADDRESS)(ImageContext.SectionAlignment - 1));
+ ImageContext.ImageAddress &= ~((EFI_PHYSICAL_ADDRESS)ImageContext.SectionAlignment - 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 a973d2db05..dcfd61c9ba 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.
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
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 restore page table does not know each page in Nvs.
//
if (!Page1GSupport) {
- TotalPageTableSize = (UINTN)(1 + NumberOfPml4EntriesNeeded + NumberOfPml4EntriesNeeded * NumberOfPdpEntriesNeeded);
+ TotalPageTableSize = 1 + NumberOfPml4EntriesNeeded + NumberOfPml4EntriesNeeded * NumberOfPdpEntriesNeeded;
} else {
- TotalPageTableSize = (UINTN)(1 + NumberOfPml4EntriesNeeded);
+ TotalPageTableSize = 1 + NumberOfPml4EntriesNeeded;
}
TotalPageTableSize += ExtraPageTablePages;
diff --git a/MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c b/MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c index 9e8315eb97..3e7054cd38 100644 --- a/MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c +++ b/MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c @@ -10,7 +10,7 @@ into memory.
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
-Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
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 == EFI_CAPSULE_PEIM_PRIVATE_DATA_SIGNATURE);
ASSERT ((UINTN)DestPtr >= (UINTN)CapsuleImageBase);
- PrivateDataPtr->CapsuleOffset[CapsuleIndex++] = (UINT64)((UINTN)DestPtr - (UINTN)CapsuleImageBase);
+ PrivateDataPtr->CapsuleOffset[CapsuleIndex++] = (UINTN)DestPtr - (UINTN)CapsuleImageBase;
}
//
diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c index 0eb7dddf7b..e1ac5a3223 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.
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2014, Hewlett-Packard Development Company, L.P.<BR>
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 = AllocateZeroPool (((UINTN) (StrOffset + 2) * sizeof(CHAR16)));
+ *OutputString = AllocateZeroPool ((StrOffset + 2) * sizeof(CHAR16));
if (*OutputString == NULL) {
return 0;
}
@@ -2972,7 +2972,7 @@ UiDisplayMenu ( gST->ConOut->SetAttribute (gST->ConOut, GetInfoTextColor ());
for (Index = 0; Index < HelpHeaderLine; Index++) {
ASSERT (HelpHeaderLine == 1);
- ASSERT (GetStringWidth (HelpHeaderString) / 2 < (UINTN) (gHelpBlockWidth - 1));
+ ASSERT (GetStringWidth (HelpHeaderString) / 2 < ((UINT32) gHelpBlockWidth - 1));
PrintStringAtWithWidth (
gStatementDimensions.RightColumn - gHelpBlockWidth,
Index + TopRow,
@@ -3053,7 +3053,7 @@ UiDisplayMenu ( gST->ConOut->SetAttribute (gST->ConOut, GetInfoTextColor ());
for (Index = 0; Index < HelpBottomLine; Index++) {
ASSERT (HelpBottomLine == 1);
- ASSERT (GetStringWidth (HelpBottomString) / 2 < (UINTN) (gHelpBlockWidth - 1));
+ ASSERT (GetStringWidth (HelpBottomString) / 2 < ((UINT32) gHelpBlockWidth - 1));
PrintStringAtWithWidth (
gStatementDimensions.RightColumn - gHelpBlockWidth,
BottomRow + Index - HelpBottomLine + 1,
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c b/MdeModulePkg/Universal/EbcDxe/EbcExecute.c index e5d290a2fe..2dfed8ecf5 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.
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
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)] = (INT64) (UINT64) ((UINTN) DataN + Index16);
+ VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (INT64) (UINT64) (UINTN) (DataN + Index16);
}
return EFI_SUCCESS;
@@ -3592,7 +3592,7 @@ ExecuteSUB ( if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
return (UINT64) ((INT64) ((INT64) Op1 - (INT64) Op2));
} else {
- return (UINT64) ((INT64) ((INT32) Op1 - (INT32) Op2));
+ return (UINT64) ((INT64) ((INT32) ((INT32) Op1 - (INT32) Op2)));
}
}
@@ -3620,7 +3620,7 @@ ExecuteMUL ( if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
return MultS64x64 ((INT64)Op1, (INT64)Op2);
} else {
- return (UINT64) ((INT64) ((INT32) Op1 * (INT32) Op2));
+ return (UINT64) ((INT64) ((INT32) ((INT32) Op1 * (INT32) Op2)));
}
}
@@ -3648,7 +3648,7 @@ ExecuteMULU ( if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
return MultU64x64 (Op1, Op2);
} else {
- return (UINT64) ((UINT32) Op1 * (UINT32) Op2);
+ return (UINT64) ((UINT32) ((UINT32) Op1 * (UINT32) Op2));
}
}
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c index d46a37fde3..b4327b5619 100644 --- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c +++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c @@ -2,7 +2,7 @@ Internal functions to operate Working Block Space.
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
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
@@ -55,7 +55,7 @@ InitializeLocalWorkSpaceHeader ( &gEdkiiWorkingBlockSignatureGuid,
sizeof (EFI_GUID)
);
- mWorkingBlockHeader.WriteQueueSize = (UINT64) (PcdGet32 (PcdFlashNvStorageFtwWorkingSize) - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER));
+ mWorkingBlockHeader.WriteQueueSize = PcdGet32 (PcdFlashNvStorageFtwWorkingSize) - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER);
//
// 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/Universal/HiiDatabaseDxe/Font.c index 9bef0642af..b85cf88f54 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c @@ -2,7 +2,7 @@ Implementation for EFI_HII_FONT_PROTOCOL.
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
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 = 0; Ypos < Cell->Height && ((UINTN) (Ypos + YposOffset) < RowHeight); Ypos++) {
+ for (Ypos = 0; Ypos < Cell->Height && (((UINT32) Ypos + YposOffset) < RowHeight); Ypos++) {
OffsetY = BITMAP_LEN_1_BIT (Cell->Width, Ypos);
//
@@ -419,7 +419,7 @@ GlyphToBlt ( //
for (Xpos = 0; Xpos < Cell->Width / 8; Xpos++) {
Data = *(GlyphBuffer + OffsetY + Xpos);
- for (Index = 0; Index < 8 && ((UINTN) (Xpos * 8 + Index + Cell->OffsetX) < RowWidth); Index++) {
+ for (Index = 0; Index < 8 && (((UINT32) Xpos * 8 + Index + Cell->OffsetX) < RowWidth); Index++) {
if ((Data & (1 << (8 - Index - 1))) != 0) {
BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Foreground;
} else {
@@ -435,7 +435,7 @@ GlyphToBlt ( // There are some padding bits in this byte. Ignore them.
//
Data = *(GlyphBuffer + OffsetY + Xpos);
- for (Index = 0; Index < Cell->Width % 8 && ((UINTN) (Xpos * 8 + Index + Cell->OffsetX) < RowWidth); Index++) {
+ for (Index = 0; Index < Cell->Width % 8 && (((UINT32) Xpos * 8 + Index + Cell->OffsetX) < RowWidth); Index++) {
if ((Data & (1 << (8 - Index - 1))) != 0) {
BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = 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 -= (UINTN) (Cell[Index].AdvanceX - Cell[Index].Width - Cell[Index].OffsetX);
+ LineWidth -= (Cell[Index].AdvanceX - Cell[Index].Width - Cell[Index].OffsetX);
//
// Clip the right-most character if cannot fit when EFI_HII_OUT_FLAG_CLEAN_X is set.
@@ -1950,8 +1950,8 @@ HiiStringToImage ( //
// Don't draw the last char on this row. And, don't draw the second last char (AdvanceX - Width - OffsetX).
//
- LineWidth -= (UINTN) (Cell[Index].Width + Cell[Index].OffsetX);
- LineWidth -= (UINTN) (Cell[Index - 1].AdvanceX - Cell[Index - 1].Width - Cell[Index - 1].OffsetX);
+ LineWidth -= (Cell[Index].Width + Cell[Index].OffsetX);
+ LineWidth -= (Cell[Index - 1].AdvanceX - Cell[Index - 1].Width - Cell[Index - 1].OffsetX);
RowInfo[RowIndex].EndIndex = Index - 1;
RowInfo[RowIndex].LineWidth = LineWidth;
RowInfo[RowIndex].LineHeight = LineHeight;
@@ -2008,7 +2008,7 @@ HiiStringToImage ( if (Index1 == RowInfo[RowIndex].StartIndex) {
LineWidth = 0;
} else {
- LineWidth -= (UINTN) (Cell[Index1 - 1].AdvanceX - Cell[Index1 - 1].Width - Cell[Index1 - 1].OffsetX);
+ LineWidth -= (Cell[Index1 - 1].AdvanceX - Cell[Index1 - 1].Width - Cell[Index1 - 1].OffsetX);
}
RowInfo[RowIndex].LineWidth = LineWidth;
}
@@ -2025,8 +2025,8 @@ HiiStringToImage ( //
// Don't draw the last char on this row. And, don't draw the second last char (AdvanceX - Width - OffsetX).
//
- LineWidth -= (UINTN) (Cell[Index1].Width + Cell[Index1].OffsetX);
- LineWidth -= (UINTN) (Cell[Index1 - 1].AdvanceX - Cell[Index1 - 1].Width - Cell[Index1 - 1].OffsetX);
+ LineWidth -= (Cell[Index1].Width + Cell[Index1].OffsetX);
+ LineWidth -= (Cell[Index1 - 1].AdvanceX - Cell[Index1 - 1].Width - Cell[Index1 - 1].OffsetX);
RowInfo[RowIndex].EndIndex = Index1 - 1;
RowInfo[RowIndex].LineWidth = LineWidth;
} else {
diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c index 639da4880f..cd00f5c52d 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c @@ -1,7 +1,7 @@ /** @file
Interface routines for PxeBc.
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
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 layers.
//
- Private->BlockSize = (UINTN) (MIN (Private->Ip4MaxPacketSize, PXEBC_DEFAULT_PACKET_SIZE) -
- PXEBC_DEFAULT_UDP_OVERHEAD_SIZE - PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE);
+ Private->BlockSize = MIN (Private->Ip4MaxPacketSize, PXEBC_DEFAULT_PACKET_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/Universal/PCD/Dxe/Service.c index bf77130170..efe72483c5 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.
Copyright (c) 2014, Hewlett-Packard Development Company, L.P.<BR>
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
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 = (VPD_HEAD *) ((UINT8 *) PcdDb + Offset);
- RetPtr = (VOID *) (UINTN) (PcdGet32 (PcdVpdBaseAddress) + VpdHead->Offset);
+ RetPtr = (VOID *) ((UINTN) PcdGet32 (PcdVpdBaseAddress) + VpdHead->Offset);
break;
diff --git a/MdeModulePkg/Universal/PCD/Pei/Service.c b/MdeModulePkg/Universal/PCD/Pei/Service.c index 66ca892ed2..5e1cb72ba5 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.
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
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 = (VPD_HEAD *) ((UINT8 *)PeiPcdDb + Offset);
- return (VOID *) (UINTN) (PcdGet32 (PcdVpdBaseAddress) + VpdHead->Offset);
+ return (VOID *) ((UINTN) PcdGet32 (PcdVpdBaseAddress) + VpdHead->Offset);
}
case PCD_TYPE_HII|PCD_TYPE_STRING:
diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c index ea762d59b9..4e757e1c47 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 constructing
SMBIOS table into system table.
-Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
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
@@ -1138,7 +1138,7 @@ SmbiosCreateTable ( EntryPointStructure->MaxStructureSize = (UINT16) sizeof (EndStructure);
}
- if ((UINTN) EFI_SIZE_TO_PAGES (EntryPointStructure->TableLength) > mPreAllocatedPages) {
+ if (EFI_SIZE_TO_PAGES ((UINT32) EntryPointStructure->TableLength) > mPreAllocatedPages) {
//
// If new SMBIOS table size exceeds the previous allocated page,
// it is time to re-allocate memory (below 4GB).
@@ -1307,7 +1307,7 @@ SmbiosCreate64BitTable ( EndStructure.Tailing[1] = 0;
Smbios30EntryPointStructure->TableMaximumSize = (UINT32) (Smbios30EntryPointStructure->TableMaximumSize + sizeof (EndStructure));
- if ((UINTN) EFI_SIZE_TO_PAGES (Smbios30EntryPointStructure->TableMaximumSize) > mPre64BitAllocatedPages) {
+ if (EFI_SIZE_TO_PAGES (Smbios30EntryPointStructure->TableMaximumSize) > mPre64BitAllocatedPages) {
//
// If new SMBIOS table size exceeds the previous allocated page,
// it is time to re-allocate memory at anywhere.
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c index b0c7434bae..0a325de165 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -3754,8 +3754,8 @@ InitNonVolatileVariableStore ( return EFI_VOLUME_CORRUPTED;
}
- VariableStoreBase = (EFI_PHYSICAL_ADDRESS) ((UINTN) FvHeader + FvHeader->HeaderLength);
- VariableStoreLength = (UINT64) (NvStorageSize - FvHeader->HeaderLength);
+ VariableStoreBase = (UINTN) FvHeader + FvHeader->HeaderLength;
+ VariableStoreLength = NvStorageSize - FvHeader->HeaderLength;
mNvFvHeaderCache = FvHeader;
mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase = VariableStoreBase;
@@ -4099,7 +4099,7 @@ VariableCommonInitialize ( GuidHob = GetFirstGuidHob (VariableGuid);
if (GuidHob != NULL) {
VariableStoreHeader = GET_GUID_HOB_DATA (GuidHob);
- VariableStoreLength = (UINT64) (GuidHob->Header.HobLength - sizeof (EFI_HOB_GUID_TYPE));
+ VariableStoreLength = GuidHob->Header.HobLength - sizeof (EFI_HOB_GUID_TYPE);
if (GetVariableStoreStatus (VariableStoreHeader) == EfiValid) {
mVariableModuleGlobal->VariableGlobal.HobVariableBase = (EFI_PHYSICAL_ADDRESS) (UINTN) AllocateRuntimeCopyPool ((UINTN) VariableStoreLength, (VOID *) VariableStoreHeader);
if (mVariableModuleGlobal->VariableGlobal.HobVariableBase == 0) {
|