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>
This commit is contained in:
Hao Wu
2017-02-24 10:01:34 +08:00
parent 95ba3d92dc
commit 16f6922709
34 changed files with 110 additions and 118 deletions

View File

@ -399,7 +399,7 @@ ConvertProcessorToString (
if (Base10Exponent >= 6) { if (Base10Exponent >= 6) {
FreqMhz = ProcessorFrequency; FreqMhz = ProcessorFrequency;
for (Index = 0; Index < (UINTN) (Base10Exponent - 6); Index++) { for (Index = 0; Index < (UINT32) Base10Exponent - 6; Index++) {
FreqMhz *= 10; FreqMhz *= 10;
} }
} else { } else {

View File

@ -2,7 +2,7 @@
The EHCI register operation routines. The EHCI register operation routines.
Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR> Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -76,7 +76,7 @@ EhcReadDbgRegister (
Ehc->PciIo, Ehc->PciIo,
EfiPciIoWidthUint32, EfiPciIoWidthUint32,
Ehc->DebugPortBarNum, Ehc->DebugPortBarNum,
(UINT64) (Ehc->DebugPortOffset + Offset), Ehc->DebugPortOffset + Offset,
1, 1,
&Data &Data
); );
@ -115,7 +115,7 @@ EhcReadOpReg (
Ehc->PciIo, Ehc->PciIo,
EfiPciIoWidthUint32, EfiPciIoWidthUint32,
EHC_BAR_INDEX, EHC_BAR_INDEX,
(UINT64) (Ehc->CapLen + Offset), Ehc->CapLen + Offset,
1, 1,
&Data &Data
); );
@ -152,7 +152,7 @@ EhcWriteOpReg (
Ehc->PciIo, Ehc->PciIo,
EfiPciIoWidthUint32, EfiPciIoWidthUint32,
EHC_BAR_INDEX, EHC_BAR_INDEX,
(UINT64) (Ehc->CapLen + Offset), Ehc->CapLen + Offset,
1, 1,
&Data &Data
); );

View File

@ -5,7 +5,7 @@ ATA controllers in the platform.
This PPI can be consumed by PEIM which produce gEfiPeiDeviceRecoveryModulePpiGuid This PPI can be consumed by PEIM which produce gEfiPeiDeviceRecoveryModulePpiGuid
for Atapi CD ROM device. for Atapi CD ROM device.
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 This program and the accompanying materials
are licensed and made available under the terms and conditions are licensed and made available under the terms and conditions
@ -593,7 +593,7 @@ AtapiEnumerateDevices (
// //
// Pata & Sata, Primary & Secondary channel, Master & Slave device // Pata & Sata, Primary & Secondary channel, Master & Slave device
// //
DevicePosition = (UINTN) (Index1 * 2 + Index2); DevicePosition = Index1 * 2 + Index2;
if (DiscoverAtapiDevice (AtapiBlkIoDev, DevicePosition, &MediaInfo, &MediaInfo2)) { if (DiscoverAtapiDevice (AtapiBlkIoDev, DevicePosition, &MediaInfo, &MediaInfo2)) {
// //

View File

@ -305,7 +305,7 @@ GetOpRomInfo (
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
PciIoDevice->RomSize = (UINT64) ((~AllOnes) + 1); PciIoDevice->RomSize = (~AllOnes) + 1;
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -2,7 +2,7 @@
The XHCI register operation routines. The XHCI register operation routines.
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 This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -112,7 +112,7 @@ XhcReadOpReg (
Xhc->PciIo, Xhc->PciIo,
EfiPciIoWidthUint32, EfiPciIoWidthUint32,
XHC_BAR_INDEX, XHC_BAR_INDEX,
(UINT64) (Xhc->CapLength + Offset), Xhc->CapLength + Offset,
1, 1,
&Data &Data
); );
@ -148,7 +148,7 @@ XhcWriteOpReg (
Xhc->PciIo, Xhc->PciIo,
EfiPciIoWidthUint32, EfiPciIoWidthUint32,
XHC_BAR_INDEX, XHC_BAR_INDEX,
(UINT64) (Xhc->CapLength + Offset), Xhc->CapLength + Offset,
1, 1,
&Data &Data
); );
@ -181,7 +181,7 @@ XhcWriteOpReg16 (
Xhc->PciIo, Xhc->PciIo,
EfiPciIoWidthUint16, EfiPciIoWidthUint16,
XHC_BAR_INDEX, XHC_BAR_INDEX,
(UINT64) (Xhc->CapLength + Offset), Xhc->CapLength + Offset,
1, 1,
&Data &Data
); );
@ -215,7 +215,7 @@ XhcReadDoorBellReg (
Xhc->PciIo, Xhc->PciIo,
EfiPciIoWidthUint32, EfiPciIoWidthUint32,
XHC_BAR_INDEX, XHC_BAR_INDEX,
(UINT64) (Xhc->DBOff + Offset), Xhc->DBOff + Offset,
1, 1,
&Data &Data
); );
@ -251,7 +251,7 @@ XhcWriteDoorBellReg (
Xhc->PciIo, Xhc->PciIo,
EfiPciIoWidthUint32, EfiPciIoWidthUint32,
XHC_BAR_INDEX, XHC_BAR_INDEX,
(UINT64) (Xhc->DBOff + Offset), Xhc->DBOff + Offset,
1, 1,
&Data &Data
); );
@ -285,7 +285,7 @@ XhcReadRuntimeReg (
Xhc->PciIo, Xhc->PciIo,
EfiPciIoWidthUint32, EfiPciIoWidthUint32,
XHC_BAR_INDEX, XHC_BAR_INDEX,
(UINT64) (Xhc->RTSOff + Offset), Xhc->RTSOff + Offset,
1, 1,
&Data &Data
); );
@ -321,7 +321,7 @@ XhcWriteRuntimeReg (
Xhc->PciIo, Xhc->PciIo,
EfiPciIoWidthUint32, EfiPciIoWidthUint32,
XHC_BAR_INDEX, XHC_BAR_INDEX,
(UINT64) (Xhc->RTSOff + Offset), Xhc->RTSOff + Offset,
1, 1,
&Data &Data
); );
@ -355,7 +355,7 @@ XhcReadExtCapReg (
Xhc->PciIo, Xhc->PciIo,
EfiPciIoWidthUint32, EfiPciIoWidthUint32,
XHC_BAR_INDEX, XHC_BAR_INDEX,
(UINT64) (Xhc->ExtCapRegBase + Offset), Xhc->ExtCapRegBase + Offset,
1, 1,
&Data &Data
); );
@ -391,7 +391,7 @@ XhcWriteExtCapReg (
Xhc->PciIo, Xhc->PciIo,
EfiPciIoWidthUint32, EfiPciIoWidthUint32,
XHC_BAR_INDEX, XHC_BAR_INDEX,
(UINT64) (Xhc->ExtCapRegBase + Offset), Xhc->ExtCapRegBase + Offset,
1, 1,
&Data &Data
); );

View File

@ -1,6 +1,6 @@
/** @file /** @file
Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR> Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -589,9 +589,9 @@ UfsCreateDMCommandDesc (
Trd->UcdBaU = (UINT32)RShiftU64 ((UINT64)(UINTN)QueryReqUpiu, 32); Trd->UcdBaU = (UINT32)RShiftU64 ((UINT64)(UINTN)QueryReqUpiu, 32);
if (Opcode == UtpQueryFuncOpcodeWrDesc) { if (Opcode == UtpQueryFuncOpcodeWrDesc) {
Trd->RuL = (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_RESP_UPIU)), sizeof (UINT32)); Trd->RuL = (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_RESP_UPIU)), sizeof (UINT32));
Trd->RuO = (UINT16)DivU64x32 ((UINT64)(ROUNDUP8 (sizeof (UTP_QUERY_REQ_UPIU)) + ROUNDUP8 (DataSize)), sizeof (UINT32)); Trd->RuO = (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_REQ_UPIU)) + ROUNDUP8 (DataSize), sizeof (UINT32));
} else { } else {
Trd->RuL = (UINT16)DivU64x32 ((UINT64)(ROUNDUP8 (sizeof (UTP_QUERY_RESP_UPIU)) + ROUNDUP8 (DataSize)), sizeof (UINT32)); Trd->RuL = (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_RESP_UPIU)) + ROUNDUP8 (DataSize), sizeof (UINT32));
Trd->RuO = (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_REQ_UPIU)), sizeof (UINT32)); Trd->RuO = (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_REQ_UPIU)), sizeof (UINT32));
} }

View File

@ -2,7 +2,7 @@
UfsPassThruDxe driver is used to produce EFI_EXT_SCSI_PASS_THRU protocol interface UfsPassThruDxe driver is used to produce EFI_EXT_SCSI_PASS_THRU protocol interface
for upper layer application to execute UFS-supported SCSI cmds. for upper layer application to execute UFS-supported SCSI cmds.
Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR> Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -666,9 +666,9 @@ UfsCreateDMCommandDesc (
Trd->UcdBaU = (UINT32)RShiftU64 ((UINT64)CmdDescPhyAddr, 32); Trd->UcdBaU = (UINT32)RShiftU64 ((UINT64)CmdDescPhyAddr, 32);
if (Opcode == UtpQueryFuncOpcodeWrDesc) { if (Opcode == UtpQueryFuncOpcodeWrDesc) {
Trd->RuL = (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_RESP_UPIU)), sizeof (UINT32)); Trd->RuL = (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_RESP_UPIU)), sizeof (UINT32));
Trd->RuO = (UINT16)DivU64x32 ((UINT64)(ROUNDUP8 (sizeof (UTP_QUERY_REQ_UPIU)) + ROUNDUP8 (DataSize)), sizeof (UINT32)); Trd->RuO = (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_REQ_UPIU)) + ROUNDUP8 (DataSize), sizeof (UINT32));
} else { } else {
Trd->RuL = (UINT16)DivU64x32 ((UINT64)(ROUNDUP8 (sizeof (UTP_QUERY_RESP_UPIU)) + ROUNDUP8 (DataSize)), sizeof (UINT32)); Trd->RuL = (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_RESP_UPIU)) + ROUNDUP8 (DataSize), sizeof (UINT32));
Trd->RuO = (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_REQ_UPIU)), sizeof (UINT32)); Trd->RuO = (UINT16)DivU64x32 ((UINT64)ROUNDUP8 (sizeof (UTP_QUERY_REQ_UPIU)), sizeof (UINT32));
} }

View File

@ -313,8 +313,8 @@ CheckAndMarkFixLoadingMemoryUsageBitMap (
// //
// Test if the memory is avalaible or not. // Test if the memory is avalaible or not.
// //
BaseOffsetPageNumber = (UINTN)EFI_SIZE_TO_PAGES((UINT32)(ImageBase - DxeCodeBase)); BaseOffsetPageNumber = EFI_SIZE_TO_PAGES((UINT32)(ImageBase - DxeCodeBase));
TopOffsetPageNumber = (UINTN)EFI_SIZE_TO_PAGES((UINT32)(ImageBase + ImageSize - DxeCodeBase)); TopOffsetPageNumber = EFI_SIZE_TO_PAGES((UINT32)(ImageBase + ImageSize - DxeCodeBase));
for (Index = BaseOffsetPageNumber; Index < TopOffsetPageNumber; Index ++) { for (Index = BaseOffsetPageNumber; Index < TopOffsetPageNumber; Index ++) {
if ((mDxeCodeMemoryRangeUsageBitMap[Index / 64] & LShiftU64(1, (Index % 64))) != 0) { if ((mDxeCodeMemoryRangeUsageBitMap[Index / 64] & LShiftU64(1, (Index % 64))) != 0) {
// //
@ -366,12 +366,10 @@ GetPeCoffImageFixLoadingAssignedAddress(
// //
Handle = (IMAGE_FILE_HANDLE*)ImageContext->Handle; Handle = (IMAGE_FILE_HANDLE*)ImageContext->Handle;
ImgHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((CHAR8* )Handle->Source + ImageContext->PeCoffHeaderOffset); ImgHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((CHAR8* )Handle->Source + ImageContext->PeCoffHeaderOffset);
SectionHeaderOffset = (UINTN)( SectionHeaderOffset = ImageContext->PeCoffHeaderOffset +
ImageContext->PeCoffHeaderOffset +
sizeof (UINT32) + sizeof (UINT32) +
sizeof (EFI_IMAGE_FILE_HEADER) + sizeof (EFI_IMAGE_FILE_HEADER) +
ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader;
);
NumberOfSections = ImgHdr->Pe32.FileHeader.NumberOfSections; NumberOfSections = ImgHdr->Pe32.FileHeader.NumberOfSections;
// //

View File

@ -2,7 +2,7 @@
Support functions for managing debug image info table when loading and unloading Support functions for managing debug image info table when loading and unloading
images. images.
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -103,7 +103,7 @@ CoreInitializeDebugImageInfoTable (
Status = CoreFreePages (Memory, UnalignedPages); Status = CoreFreePages (Memory, UnalignedPages);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
Memory = (EFI_PHYSICAL_ADDRESS)(AlignedMemory + EFI_PAGES_TO_SIZE (Pages)); Memory = AlignedMemory + EFI_PAGES_TO_SIZE (Pages);
UnalignedPages = RealPages - Pages - UnalignedPages; UnalignedPages = RealPages - Pages - UnalignedPages;
if (UnalignedPages > 0) { if (UnalignedPages > 0) {
// //

View File

@ -1,7 +1,7 @@
/** @file /** @file
Pei Core Load Image Support Pei Core Load Image Support
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 This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -251,12 +251,10 @@ GetPeCoffImageFixLoadingAssignedAddress(
SectionHeaderOffset = sizeof (EFI_TE_IMAGE_HEADER); SectionHeaderOffset = sizeof (EFI_TE_IMAGE_HEADER);
NumberOfSections = ImgHdr->Te.NumberOfSections; NumberOfSections = ImgHdr->Te.NumberOfSections;
} else { } else {
SectionHeaderOffset = (UINTN)( SectionHeaderOffset = ImageContext->PeCoffHeaderOffset +
ImageContext->PeCoffHeaderOffset +
sizeof (UINT32) + sizeof (UINT32) +
sizeof (EFI_IMAGE_FILE_HEADER) + sizeof (EFI_IMAGE_FILE_HEADER) +
ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader;
);
NumberOfSections = ImgHdr->Pe32.FileHeader.NumberOfSections; NumberOfSections = ImgHdr->Pe32.FileHeader.NumberOfSections;
} }
// //

View File

@ -28,7 +28,7 @@
Depex - Dependency Expresion. Depex - Dependency Expresion.
Copyright (c) 2014, Hewlett-Packard Development Company, L.P. Copyright (c) 2014, Hewlett-Packard Development Company, L.P.
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 This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this under the terms and conditions of the BSD License which accompanies this
distribution. The full text of the license may be found at distribution. The full text of the license may be found at
@ -183,8 +183,8 @@ CheckAndMarkFixLoadingMemoryUsageBitMap (
// //
// Test if the memory is avalaible or not. // Test if the memory is avalaible or not.
// //
BaseOffsetPageNumber = (UINTN)EFI_SIZE_TO_PAGES((UINT32)(ImageBase - SmmCodeBase)); BaseOffsetPageNumber = EFI_SIZE_TO_PAGES((UINT32)(ImageBase - SmmCodeBase));
TopOffsetPageNumber = (UINTN)EFI_SIZE_TO_PAGES((UINT32)(ImageBase + ImageSize - SmmCodeBase)); TopOffsetPageNumber = EFI_SIZE_TO_PAGES((UINT32)(ImageBase + ImageSize - SmmCodeBase));
for (Index = BaseOffsetPageNumber; Index < TopOffsetPageNumber; Index ++) { for (Index = BaseOffsetPageNumber; Index < TopOffsetPageNumber; Index ++) {
if ((mSmmCodeMemoryRangeUsageBitMap[Index / 64] & LShiftU64(1, (Index % 64))) != 0) { if ((mSmmCodeMemoryRangeUsageBitMap[Index / 64] & LShiftU64(1, (Index % 64))) != 0) {
// //
@ -234,12 +234,10 @@ GetPeCoffImageFixLoadingAssignedAddress(
// Get PeHeader pointer // Get PeHeader pointer
// //
ImgHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((CHAR8* )ImageContext->Handle + ImageContext->PeCoffHeaderOffset); ImgHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((CHAR8* )ImageContext->Handle + ImageContext->PeCoffHeaderOffset);
SectionHeaderOffset = (UINTN)( SectionHeaderOffset = ImageContext->PeCoffHeaderOffset +
ImageContext->PeCoffHeaderOffset +
sizeof (UINT32) + sizeof (UINT32) +
sizeof (EFI_IMAGE_FILE_HEADER) + sizeof (EFI_IMAGE_FILE_HEADER) +
ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader;
);
NumberOfSections = ImgHdr->Pe32.FileHeader.NumberOfSections; NumberOfSections = ImgHdr->Pe32.FileHeader.NumberOfSections;
// //
@ -520,7 +518,7 @@ SmmLoadImage (
// Align buffer on section boundary // Align buffer on section boundary
// //
ImageContext.ImageAddress += ImageContext.SectionAlignment - 1; 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 // Load the image to our new buffer

View File

@ -846,12 +846,10 @@ GetPeCoffImageFixLoadingAssignedAddress(
// Get PeHeader pointer // Get PeHeader pointer
// //
ImgHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((CHAR8* )ImageContext->Handle + ImageContext->PeCoffHeaderOffset); ImgHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((CHAR8* )ImageContext->Handle + ImageContext->PeCoffHeaderOffset);
SectionHeaderOffset = (UINTN)( SectionHeaderOffset = ImageContext->PeCoffHeaderOffset +
ImageContext->PeCoffHeaderOffset +
sizeof (UINT32) + sizeof (UINT32) +
sizeof (EFI_IMAGE_FILE_HEADER) + sizeof (EFI_IMAGE_FILE_HEADER) +
ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader;
);
NumberOfSections = ImgHdr->Pe32.FileHeader.NumberOfSections; NumberOfSections = ImgHdr->Pe32.FileHeader.NumberOfSections;
// //
@ -1022,7 +1020,7 @@ ExecuteSmmCoreFromSmram (
} }
ImageContext.ImageAddress += ImageContext.SectionAlignment - 1; ImageContext.ImageAddress += ImageContext.SectionAlignment - 1;
ImageContext.ImageAddress &= ~((EFI_PHYSICAL_ADDRESS)(ImageContext.SectionAlignment - 1)); ImageContext.ImageAddress &= ~((EFI_PHYSICAL_ADDRESS)ImageContext.SectionAlignment - 1);
// //
// Print debug message showing SMM Core load address. // Print debug message showing SMM Core load address.

View File

@ -585,7 +585,7 @@ DisplayCapsuleImage (
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
ImagePayload = (DISPLAY_DISPLAY_PAYLOAD *)(CapsuleHeader + 1); ImagePayload = (DISPLAY_DISPLAY_PAYLOAD *)(CapsuleHeader + 1);
PayloadSize = (UINTN)(CapsuleHeader->CapsuleImageSize - sizeof(EFI_CAPSULE_HEADER)); PayloadSize = CapsuleHeader->CapsuleImageSize - sizeof(EFI_CAPSULE_HEADER);
if (ImagePayload->Version != 1) { if (ImagePayload->Version != 1) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
@ -733,7 +733,7 @@ DumpFmpCapsule (
for (Index = 0; Index < FmpCapsuleHeader->EmbeddedDriverCount; Index++) { for (Index = 0; Index < FmpCapsuleHeader->EmbeddedDriverCount; Index++) {
DEBUG((DEBUG_VERBOSE, " ItemOffsetList[%d] - 0x%lx\n", Index, ItemOffsetList[Index])); DEBUG((DEBUG_VERBOSE, " ItemOffsetList[%d] - 0x%lx\n", Index, ItemOffsetList[Index]));
} }
for (; Index < (UINTN)(FmpCapsuleHeader->EmbeddedDriverCount + FmpCapsuleHeader->PayloadItemCount); Index++) { for (; Index < (UINT32)FmpCapsuleHeader->EmbeddedDriverCount + FmpCapsuleHeader->PayloadItemCount; Index++) {
DEBUG((DEBUG_VERBOSE, " ItemOffsetList[%d] - 0x%lx\n", Index, ItemOffsetList[Index])); DEBUG((DEBUG_VERBOSE, " ItemOffsetList[%d] - 0x%lx\n", Index, ItemOffsetList[Index]));
ImageHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index]); ImageHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index]);

View File

@ -3,7 +3,7 @@
on DxeCore Memory Allocation services for DxeCore, on DxeCore Memory Allocation services for DxeCore,
with memory profile support. with memory profile support.
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 This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -258,7 +258,7 @@ InternalAllocateAlignedPages (
Status = CoreFreePages (Memory, UnalignedPages); Status = CoreFreePages (Memory, UnalignedPages);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
Memory = (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages)); Memory = AlignedMemory + EFI_PAGES_TO_SIZE (Pages);
UnalignedPages = RealPages - Pages - UnalignedPages; UnalignedPages = RealPages - Pages - UnalignedPages;
if (UnalignedPages > 0) { if (UnalignedPages > 0) {
// //

View File

@ -2995,7 +2995,7 @@ NetLibGetSystemGuid (
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
Smbios.Hdr = (SMBIOS_STRUCTURE *) (UINTN) SmbiosTable->TableAddress; Smbios.Hdr = (SMBIOS_STRUCTURE *) (UINTN) SmbiosTable->TableAddress;
SmbiosEnd.Raw = (UINT8 *) (UINTN) (SmbiosTable->TableAddress + SmbiosTable->TableLength); SmbiosEnd.Raw = (UINT8 *) ((UINTN) SmbiosTable->TableAddress + SmbiosTable->TableLength);
} }
do { do {

View File

@ -691,7 +691,7 @@ S3BootScriptGetBootTimeEntryAddAddress (
// Here we do not count the reserved memory for runtime script table. // Here we do not count the reserved memory for runtime script table.
PageNumber = (UINT16) (mS3BootScriptTablePtr->TableMemoryPageNumber - PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber)); PageNumber = (UINT16) (mS3BootScriptTablePtr->TableMemoryPageNumber - PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber));
TableLength = mS3BootScriptTablePtr->TableLength; TableLength = mS3BootScriptTablePtr->TableLength;
if ((UINTN) EFI_PAGES_TO_SIZE ((UINTN) PageNumber) < (UINTN) (TableLength + 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 // 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. // 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)) <= (UINTN) EFI_PAGES_TO_SIZE ((UINTN) (mS3BootScriptTablePtr->TableMemoryPageNumber))) { if ((mS3BootScriptTablePtr->TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE)) <= EFI_PAGES_TO_SIZE ((UINTN) (mS3BootScriptTablePtr->TableMemoryPageNumber))) {
NewEntryPtr = mS3BootScriptTablePtr->TableBase + mS3BootScriptTablePtr->TableLength; NewEntryPtr = mS3BootScriptTablePtr->TableBase + mS3BootScriptTablePtr->TableLength;
mS3BootScriptTablePtr->TableLength = mS3BootScriptTablePtr->TableLength + EntryLength; mS3BootScriptTablePtr->TableLength = mS3BootScriptTablePtr->TableLength + EntryLength;
// //

View File

@ -11,7 +11,7 @@
In addition, allocation for the Reserved memory types are not supported and will In addition, allocation for the Reserved memory types are not supported and will
always return NULL. always return NULL.
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 This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -293,7 +293,7 @@ InternalAllocateAlignedPages (
Status = SmmFreePages (Memory, UnalignedPages); Status = SmmFreePages (Memory, UnalignedPages);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
Memory = (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages)); Memory = AlignedMemory + EFI_PAGES_TO_SIZE (Pages);
UnalignedPages = RealPages - Pages - UnalignedPages; UnalignedPages = RealPages - Pages - UnalignedPages;
if (UnalignedPages > 0) { if (UnalignedPages > 0) {
// //

View File

@ -12,7 +12,7 @@
allocation for the Reserved memory types are not supported and will always allocation for the Reserved memory types are not supported and will always
return NULL. return NULL.
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 This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -371,7 +371,7 @@ InternalAllocateAlignedPages (
Status = gSmst->SmmFreePages (Memory, UnalignedPages); Status = gSmst->SmmFreePages (Memory, UnalignedPages);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
Memory = (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages)); Memory = AlignedMemory + EFI_PAGES_TO_SIZE (Pages);
UnalignedPages = RealPages - Pages - UnalignedPages; UnalignedPages = RealPages - Pages - UnalignedPages;
if (UnalignedPages > 0) { if (UnalignedPages > 0) {
// //

View File

@ -413,11 +413,11 @@ BmCharToUint (
) )
{ {
if ((Char >= L'0') && (Char <= L'9')) { if ((Char >= L'0') && (Char <= L'9')) {
return (UINTN) (Char - L'0'); return (Char - L'0');
} }
if ((Char >= L'A') && (Char <= L'F')) { if ((Char >= L'A') && (Char <= L'F')) {
return (UINTN) (Char - L'A' + 0xA); return (Char - L'A' + 0xA);
} }
ASSERT (FALSE); ASSERT (FALSE);

View File

@ -1874,7 +1874,7 @@ GetBlockDataInfo (
// //
// Check whether VarBuffer is enough // Check whether VarBuffer is enough
// //
if ((UINTN) (Offset + Width) > MaxBufferSize) { if ((UINT32)Offset + Width > MaxBufferSize) {
DataBuffer = ReallocatePool ( DataBuffer = ReallocatePool (
MaxBufferSize, MaxBufferSize,
Offset + Width + HII_LIB_DEFAULT_VARSTORE_SIZE, Offset + Width + HII_LIB_DEFAULT_VARSTORE_SIZE,

View File

@ -2,7 +2,7 @@
Support routines for memory allocation routines based Support routines for memory allocation routines based
on boot services for Dxe phase drivers, with memory profile support. on boot services for Dxe phase drivers, with memory profile support.
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 This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -257,7 +257,7 @@ InternalAllocateAlignedPages (
Status = gBS->FreePages (Memory, UnalignedPages); Status = gBS->FreePages (Memory, UnalignedPages);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
Memory = (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages)); Memory = AlignedMemory + EFI_PAGES_TO_SIZE (Pages);
UnalignedPages = RealPages - Pages - UnalignedPages; UnalignedPages = RealPages - Pages - UnalignedPages;
if (UnalignedPages > 0) { if (UnalignedPages > 0) {
// //

View File

@ -1,7 +1,7 @@
/** @file /** @file
Var Check Hii handler. Var Check Hii handler.
Copyright (c) 2015, Intel Corporation. All rights reserved.<BR> Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -94,7 +94,7 @@ VarCheckHiiQuestion (
UINT8 Index; UINT8 Index;
UINT8 MaxContainers; UINT8 MaxContainers;
if ((UINTN) (HiiQuestion->VarOffset + HiiQuestion->StorageWidth) > DataSize) { if (((UINT32) HiiQuestion->VarOffset + HiiQuestion->StorageWidth) > DataSize) {
DEBUG ((EFI_D_INFO, "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->StorageWidth, DataSize)); DEBUG ((EFI_D_INFO, "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->StorageWidth, DataSize));
return FALSE; return FALSE;
} }
@ -155,7 +155,7 @@ VarCheckHiiQuestion (
case EFI_IFR_ORDERED_LIST_OP: case EFI_IFR_ORDERED_LIST_OP:
MaxContainers = ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion)->MaxContainers; MaxContainers = ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion)->MaxContainers;
if ((UINTN) (HiiQuestion->VarOffset + HiiQuestion->StorageWidth * MaxContainers) > DataSize) { if (((UINT32) HiiQuestion->VarOffset + HiiQuestion->StorageWidth * MaxContainers) > DataSize) {
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)); 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));
return FALSE; return FALSE;
} }

View File

@ -4,7 +4,7 @@
This driver is dispatched by Dxe core and the driver will reload itself to ACPI reserved memory 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 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> Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
@ -327,7 +327,7 @@ ReadyToLockEventNotify (
// Align buffer on section boundary // Align buffer on section boundary
// //
ImageContext.ImageAddress += ImageContext.SectionAlignment - 1; 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 // Load the image to our new buffer
// //

View File

@ -1,7 +1,7 @@
/** @file /** @file
This is the implementation to save ACPI S3 Context. 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 This program and the accompanying materials
are licensed and made available under the terms and conditions 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. // We need calculate whole page size then allocate once, because S3 restore page table does not know each page in Nvs.
// //
if (!Page1GSupport) { if (!Page1GSupport) {
TotalPageTableSize = (UINTN)(1 + NumberOfPml4EntriesNeeded + NumberOfPml4EntriesNeeded * NumberOfPdpEntriesNeeded); TotalPageTableSize = 1 + NumberOfPml4EntriesNeeded + NumberOfPml4EntriesNeeded * NumberOfPdpEntriesNeeded;
} else { } else {
TotalPageTableSize = (UINTN)(1 + NumberOfPml4EntriesNeeded); TotalPageTableSize = 1 + NumberOfPml4EntriesNeeded;
} }
TotalPageTableSize += ExtraPageTablePages; TotalPageTableSize += ExtraPageTablePages;

View File

@ -10,7 +10,7 @@
into memory. into memory.
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR> (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 This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 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 (PrivateDataPtr->Signature == EFI_CAPSULE_PEIM_PRIVATE_DATA_SIGNATURE);
ASSERT ((UINTN)DestPtr >= (UINTN)CapsuleImageBase); ASSERT ((UINTN)DestPtr >= (UINTN)CapsuleImageBase);
PrivateDataPtr->CapsuleOffset[CapsuleIndex++] = (UINT64)((UINTN)DestPtr - (UINTN)CapsuleImageBase); PrivateDataPtr->CapsuleOffset[CapsuleIndex++] = (UINTN)DestPtr - (UINTN)CapsuleImageBase;
} }
// //

View File

@ -1,7 +1,7 @@
/** @file /** @file
Entry and initialization module for the browser. 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> Copyright (c) 2014, Hewlett-Packard Development Company, L.P.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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. // 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) { if (*OutputString == NULL) {
return 0; return 0;
} }
@ -2972,7 +2972,7 @@ UiDisplayMenu (
gST->ConOut->SetAttribute (gST->ConOut, GetInfoTextColor ()); gST->ConOut->SetAttribute (gST->ConOut, GetInfoTextColor ());
for (Index = 0; Index < HelpHeaderLine; Index++) { for (Index = 0; Index < HelpHeaderLine; Index++) {
ASSERT (HelpHeaderLine == 1); ASSERT (HelpHeaderLine == 1);
ASSERT (GetStringWidth (HelpHeaderString) / 2 < (UINTN) (gHelpBlockWidth - 1)); ASSERT (GetStringWidth (HelpHeaderString) / 2 < ((UINT32) gHelpBlockWidth - 1));
PrintStringAtWithWidth ( PrintStringAtWithWidth (
gStatementDimensions.RightColumn - gHelpBlockWidth, gStatementDimensions.RightColumn - gHelpBlockWidth,
Index + TopRow, Index + TopRow,
@ -3053,7 +3053,7 @@ UiDisplayMenu (
gST->ConOut->SetAttribute (gST->ConOut, GetInfoTextColor ()); gST->ConOut->SetAttribute (gST->ConOut, GetInfoTextColor ());
for (Index = 0; Index < HelpBottomLine; Index++) { for (Index = 0; Index < HelpBottomLine; Index++) {
ASSERT (HelpBottomLine == 1); ASSERT (HelpBottomLine == 1);
ASSERT (GetStringWidth (HelpBottomString) / 2 < (UINTN) (gHelpBlockWidth - 1)); ASSERT (GetStringWidth (HelpBottomString) / 2 < ((UINT32) gHelpBlockWidth - 1));
PrintStringAtWithWidth ( PrintStringAtWithWidth (
gStatementDimensions.RightColumn - gHelpBlockWidth, gStatementDimensions.RightColumn - gHelpBlockWidth,
BottomRow + Index - HelpBottomLine + 1, BottomRow + Index - HelpBottomLine + 1,

View File

@ -1,7 +1,7 @@
/** @file /** @file
Contains code that implements the virtual machine. 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 This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -2867,7 +2867,7 @@ ExecutePOPn (
if (OPERAND1_INDIRECT (Operands)) { if (OPERAND1_INDIRECT (Operands)) {
VmWriteMemN (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16), DataN); VmWriteMemN (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16), DataN);
} else { } else {
VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (INT64) (UINT64) ((UINTN) DataN + Index16); VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (INT64) (UINT64) (UINTN) (DataN + Index16);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
@ -3592,7 +3592,7 @@ ExecuteSUB (
if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) { if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
return (UINT64) ((INT64) ((INT64) Op1 - (INT64) Op2)); return (UINT64) ((INT64) ((INT64) Op1 - (INT64) Op2));
} else { } 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) { if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
return MultS64x64 ((INT64)Op1, (INT64)Op2); return MultS64x64 ((INT64)Op1, (INT64)Op2);
} else { } 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) { if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
return MultU64x64 (Op1, Op2); return MultU64x64 (Op1, Op2);
} else { } else {
return (UINT64) ((UINT32) Op1 * (UINT32) Op2); return (UINT64) ((UINT32) ((UINT32) Op1 * (UINT32) Op2));
} }
} }

View File

@ -2,7 +2,7 @@
Internal functions to operate Working Block Space. 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 This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -55,7 +55,7 @@ InitializeLocalWorkSpaceHeader (
&gEdkiiWorkingBlockSignatureGuid, &gEdkiiWorkingBlockSignatureGuid,
sizeof (EFI_GUID) 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. // Crc is calculated with all the fields except Crc and STATE, so leave them as FTW_ERASED_BYTE.

View File

@ -2,7 +2,7 @@
Implementation for EFI_HII_FONT_PROTOCOL. 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 This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 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 // The glyph's upper left hand corner pixel is the most significant bit of the
// first bitmap byte. // 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); OffsetY = BITMAP_LEN_1_BIT (Cell->Width, Ypos);
// //
@ -419,7 +419,7 @@ GlyphToBlt (
// //
for (Xpos = 0; Xpos < Cell->Width / 8; Xpos++) { for (Xpos = 0; Xpos < Cell->Width / 8; Xpos++) {
Data = *(GlyphBuffer + OffsetY + 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) { if ((Data & (1 << (8 - Index - 1))) != 0) {
BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Foreground; BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Foreground;
} else { } else {
@ -435,7 +435,7 @@ GlyphToBlt (
// There are some padding bits in this byte. Ignore them. // There are some padding bits in this byte. Ignore them.
// //
Data = *(GlyphBuffer + OffsetY + Xpos); 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) { if ((Data & (1 << (8 - Index - 1))) != 0) {
BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Foreground; BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Foreground;
} else { } else {
@ -1927,7 +1927,7 @@ HiiStringToImage (
// If this character is the last character of a row, we need not // If this character is the last character of a row, we need not
// draw its (AdvanceX - Width - OffsetX) for next character. // 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. // 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). // 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 -= (Cell[Index].Width + Cell[Index].OffsetX);
LineWidth -= (UINTN) (Cell[Index - 1].AdvanceX - Cell[Index - 1].Width - Cell[Index - 1].OffsetX); LineWidth -= (Cell[Index - 1].AdvanceX - Cell[Index - 1].Width - Cell[Index - 1].OffsetX);
RowInfo[RowIndex].EndIndex = Index - 1; RowInfo[RowIndex].EndIndex = Index - 1;
RowInfo[RowIndex].LineWidth = LineWidth; RowInfo[RowIndex].LineWidth = LineWidth;
RowInfo[RowIndex].LineHeight = LineHeight; RowInfo[RowIndex].LineHeight = LineHeight;
@ -2008,7 +2008,7 @@ HiiStringToImage (
if (Index1 == RowInfo[RowIndex].StartIndex) { if (Index1 == RowInfo[RowIndex].StartIndex) {
LineWidth = 0; LineWidth = 0;
} else { } 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; 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). // 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 -= (Cell[Index1].Width + Cell[Index1].OffsetX);
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].EndIndex = Index1 - 1; RowInfo[RowIndex].EndIndex = Index1 - 1;
RowInfo[RowIndex].LineWidth = LineWidth; RowInfo[RowIndex].LineWidth = LineWidth;
} else { } else {

View File

@ -1,7 +1,7 @@
/** @file /** @file
Interface routines for PxeBc. 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 This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 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. // Configure block size for TFTP as a default value to handle all link layers.
// //
Private->BlockSize = (UINTN) (MIN (Private->Ip4MaxPacketSize, PXEBC_DEFAULT_PACKET_SIZE) - Private->BlockSize = MIN (Private->Ip4MaxPacketSize, PXEBC_DEFAULT_PACKET_SIZE) -
PXEBC_DEFAULT_UDP_OVERHEAD_SIZE - PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE); PXEBC_DEFAULT_UDP_OVERHEAD_SIZE - PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE;
// //
// If PcdTftpBlockSize is set to non-zero, override the default value. // If PcdTftpBlockSize is set to non-zero, override the default value.
// //

View File

@ -2,7 +2,7 @@
Help functions used by PCD DXE driver. Help functions used by PCD DXE driver.
Copyright (c) 2014, Hewlett-Packard Development Company, L.P.<BR> 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> (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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) { switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {
case PCD_TYPE_VPD: case PCD_TYPE_VPD:
VpdHead = (VPD_HEAD *) ((UINT8 *) PcdDb + Offset); VpdHead = (VPD_HEAD *) ((UINT8 *) PcdDb + Offset);
RetPtr = (VOID *) (UINTN) (PcdGet32 (PcdVpdBaseAddress) + VpdHead->Offset); RetPtr = (VOID *) ((UINTN) PcdGet32 (PcdVpdBaseAddress) + VpdHead->Offset);
break; break;

View File

@ -2,7 +2,7 @@
The driver internal functions are implmented here. The driver internal functions are implmented here.
They build Pei PCD database, and provide access service to PCD database. 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 This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -985,7 +985,7 @@ GetWorker (
{ {
VPD_HEAD *VpdHead; VPD_HEAD *VpdHead;
VpdHead = (VPD_HEAD *) ((UINT8 *)PeiPcdDb + Offset); 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: case PCD_TYPE_HII|PCD_TYPE_STRING:

View File

@ -2,7 +2,7 @@
This code produces the Smbios protocol. It also responsible for constructing This code produces the Smbios protocol. It also responsible for constructing
SMBIOS table into system table. 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 This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -1138,7 +1138,7 @@ SmbiosCreateTable (
EntryPointStructure->MaxStructureSize = (UINT16) sizeof (EndStructure); 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, // If new SMBIOS table size exceeds the previous allocated page,
// it is time to re-allocate memory (below 4GB). // it is time to re-allocate memory (below 4GB).
@ -1307,7 +1307,7 @@ SmbiosCreate64BitTable (
EndStructure.Tailing[1] = 0; EndStructure.Tailing[1] = 0;
Smbios30EntryPointStructure->TableMaximumSize = (UINT32) (Smbios30EntryPointStructure->TableMaximumSize + sizeof (EndStructure)); 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, // If new SMBIOS table size exceeds the previous allocated page,
// it is time to re-allocate memory at anywhere. // it is time to re-allocate memory at anywhere.

View File

@ -3754,8 +3754,8 @@ InitNonVolatileVariableStore (
return EFI_VOLUME_CORRUPTED; return EFI_VOLUME_CORRUPTED;
} }
VariableStoreBase = (EFI_PHYSICAL_ADDRESS) ((UINTN) FvHeader + FvHeader->HeaderLength); VariableStoreBase = (UINTN) FvHeader + FvHeader->HeaderLength;
VariableStoreLength = (UINT64) (NvStorageSize - FvHeader->HeaderLength); VariableStoreLength = NvStorageSize - FvHeader->HeaderLength;
mNvFvHeaderCache = FvHeader; mNvFvHeaderCache = FvHeader;
mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase = VariableStoreBase; mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase = VariableStoreBase;
@ -4099,7 +4099,7 @@ VariableCommonInitialize (
GuidHob = GetFirstGuidHob (VariableGuid); GuidHob = GetFirstGuidHob (VariableGuid);
if (GuidHob != NULL) { if (GuidHob != NULL) {
VariableStoreHeader = GET_GUID_HOB_DATA (GuidHob); 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) { if (GetVariableStoreStatus (VariableStoreHeader) == EfiValid) {
mVariableModuleGlobal->VariableGlobal.HobVariableBase = (EFI_PHYSICAL_ADDRESS) (UINTN) AllocateRuntimeCopyPool ((UINTN) VariableStoreLength, (VOID *) VariableStoreHeader); mVariableModuleGlobal->VariableGlobal.HobVariableBase = (EFI_PHYSICAL_ADDRESS) (UINTN) AllocateRuntimeCopyPool ((UINTN) VariableStoreLength, (VOID *) VariableStoreHeader);
if (mVariableModuleGlobal->VariableGlobal.HobVariableBase == 0) { if (mVariableModuleGlobal->VariableGlobal.HobVariableBase == 0) {