summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>2010-09-16 04:51:25 +0000
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>2010-09-16 04:51:25 +0000
commitcd7bfc2c632841fab110f601a32850eeddc16af1 (patch)
tree4d1f82523dd545fa241053cf52b31b8c2b915fe7
parent7bee5a761f4cbafd1e1805dfd99255a0353bbf88 (diff)
downloadedk2-platforms-cd7bfc2c632841fab110f601a32850eeddc16af1.tar.xz
Refine code to make code run safely.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10880 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c8
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c4
-rw-r--r--MdeModulePkg/Core/Dxe/Event/Tpl.c2
-rw-r--r--MdeModulePkg/Core/Dxe/Hand/Locate.c3
-rw-r--r--MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c4
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/Database.c2
-rw-r--r--MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c2
-rw-r--r--MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.c4
-rw-r--r--MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c2
-rw-r--r--MdeModulePkg/Universal/Network/SnpDxe/Transmit.c2
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c14
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Ui.c8
12 files changed, 29 insertions, 26 deletions
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
index 09b58ac0de..d5614b284a 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
@@ -1127,7 +1127,7 @@ ConstructAcpiResourceRequestor (
//
if ((Aperture & 0x02) != 0) {
Ptr->Desc = ACPI_ADDRESS_SPACE_DESCRIPTOR;
- Ptr->Len = sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3;
+ Ptr->Len = (UINT16) (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3);
//
// Mem
//
@@ -1151,7 +1151,7 @@ ConstructAcpiResourceRequestor (
//
if ((Aperture & 0x04) != 0) {
Ptr->Desc = ACPI_ADDRESS_SPACE_DESCRIPTOR;
- Ptr->Len = sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3;
+ Ptr->Len = (UINT16) (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3);
//
// Mem
//
@@ -1174,7 +1174,7 @@ ConstructAcpiResourceRequestor (
//
if ((Aperture & 0x08) != 0) {
Ptr->Desc = ACPI_ADDRESS_SPACE_DESCRIPTOR;
- Ptr->Len = sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3;
+ Ptr->Len = (UINT16) (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3);
//
// Mem
//
@@ -1197,7 +1197,7 @@ ConstructAcpiResourceRequestor (
//
if ((Aperture & 0x10) != 0) {
Ptr->Desc = ACPI_ADDRESS_SPACE_DESCRIPTOR;
- Ptr->Len = sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3;
+ Ptr->Len = (UINT16) (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3);
//
// Mem
//
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c
index 81f78cb0f7..cb892e3ebc 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c
@@ -197,12 +197,12 @@ UsbCreateDesc (
return NULL;
}
- Desc = AllocateZeroPool (CtrlLen);
+ Desc = AllocateZeroPool ((UINTN) CtrlLen);
if (Desc == NULL) {
return NULL;
}
- CopyMem (Desc, Head, DescLen);
+ CopyMem (Desc, Head, (UINTN) DescLen);
*Consumed = Offset + Head->Len;
diff --git a/MdeModulePkg/Core/Dxe/Event/Tpl.c b/MdeModulePkg/Core/Dxe/Event/Tpl.c
index 7fe9b12600..240e8e453d 100644
--- a/MdeModulePkg/Core/Dxe/Event/Tpl.c
+++ b/MdeModulePkg/Core/Dxe/Event/Tpl.c
@@ -118,7 +118,7 @@ CoreRestoreTpl (
// Dispatch any pending events
//
while (((-2 << NewTpl) & gEventPending) != 0) {
- gEfiCurrentTpl = HighBitSet64 (gEventPending);
+ gEfiCurrentTpl = (UINTN) HighBitSet64 (gEventPending);
if (gEfiCurrentTpl < TPL_HIGH_LEVEL) {
CoreSetInterruptState (TRUE);
}
diff --git a/MdeModulePkg/Core/Dxe/Hand/Locate.c b/MdeModulePkg/Core/Dxe/Hand/Locate.c
index 9714f64d95..df7fa8fa6d 100644
--- a/MdeModulePkg/Core/Dxe/Hand/Locate.c
+++ b/MdeModulePkg/Core/Dxe/Hand/Locate.c
@@ -490,7 +490,8 @@ CoreLocateDevicePath (
// Check if DevicePath is first part of SourcePath
//
Size = GetDevicePathSize (TmpDevicePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL);
- if ((Size <= SourceSize) && CompareMem (SourcePath, TmpDevicePath, Size) == 0) {
+ ASSERT (Size >= 0);
+ if ((Size <= SourceSize) && CompareMem (SourcePath, TmpDevicePath, (UINTN) Size) == 0) {
//
// If the size is equal to the best match, then we
// have a duplicate device path for 2 different device
diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
index bdea068aeb..e6f732db8b 100644
--- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
+++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
@@ -816,8 +816,8 @@ GraphicsConsoleConOutOutputString (
MaxColumn = Private->ModeData[Mode].Columns;
MaxRow = Private->ModeData[Mode].Rows;
- DeltaX = Private->ModeData[Mode].DeltaX;
- DeltaY = Private->ModeData[Mode].DeltaY;
+ DeltaX = (UINTN) Private->ModeData[Mode].DeltaX;
+ DeltaY = (UINTN) Private->ModeData[Mode].DeltaY;
Width = MaxColumn * EFI_GLYPH_WIDTH;
Height = (MaxRow - 1) * EFI_GLYPH_HEIGHT;
Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
index c80f1db055..534c5647a4 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
@@ -86,7 +86,7 @@ GenerateHiiDatabaseRecord (
// Backup the number of Hii handles
//
Private->HiiHandleCount++;
- HiiHandle->Key = Private->HiiHandleCount;
+ HiiHandle->Key = (UINTN) Private->HiiHandleCount;
//
// Insert the handle to hii handle list of the whole database.
//
diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
index e8e127da48..0884026db4 100644
--- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
+++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
@@ -467,7 +467,7 @@ DhcpCopyConfigure (
{
EFI_DHCP4_PACKET_OPTION **DstOptions;
EFI_DHCP4_PACKET_OPTION **SrcOptions;
- INTN Len;
+ UINTN Len;
UINT32 Index;
CopyMem (Dst, Src, sizeof (*Dst));
diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.c
index ff48bec7a4..d7700bccc4 100644
--- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.c
+++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.c
@@ -611,7 +611,7 @@ DhcpParseOption (
// Allocate a buffer to hold the DHCP options, and after that, a
// continuous buffer to put all the options' data.
//
- Options = AllocateZeroPool (OptNum * sizeof (DHCP_OPTION) + TotalLen);
+ Options = AllocateZeroPool ((UINTN) (OptNum * sizeof (DHCP_OPTION)) + TotalLen);
if (Options == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -754,7 +754,7 @@ DhcpAppendOption (
*(Buf++) = Tag;
*(Buf++) = (UINT8) Len;
- CopyMem (Buf, Data + Index * 255, Len);
+ CopyMem (Buf, Data + Index * 255, (UINTN) Len);
Buf += Len;
}
diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c
index bb4ce0ae65..26860e52bb 100644
--- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c
+++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c
@@ -223,7 +223,7 @@ Mtftp4RemoveBlockNum (
*TotalBlock = Num;
if (Range->Round > 0) {
- *TotalBlock += Range->Bound + MultU64x32 (Range->Round -1, (UINT32)(Range->Bound + 1)) + 1;
+ *TotalBlock += Range->Bound + MultU64x32 ((UINTN) (Range->Round -1), (UINT32) (Range->Bound + 1)) + 1;
}
if (Range->Start > Range->Bound) {
diff --git a/MdeModulePkg/Universal/Network/SnpDxe/Transmit.c b/MdeModulePkg/Universal/Network/SnpDxe/Transmit.c
index ac6b66424d..e6c5af77ec 100644
--- a/MdeModulePkg/Universal/Network/SnpDxe/Transmit.c
+++ b/MdeModulePkg/Universal/Network/SnpDxe/Transmit.c
@@ -90,7 +90,7 @@ PxeFillHeader (
Snp->Cdb.DBsize = PXE_DBSIZE_NOT_USED;
Snp->Cdb.DBaddr = PXE_DBADDR_NOT_USED;
- Snp->Cdb.CPBsize = sizeof (PXE_CPB_FILL_HEADER_FRAGMENTED);
+ Snp->Cdb.CPBsize = (UINT16) sizeof (PXE_CPB_FILL_HEADER_FRAGMENTED);
Snp->Cdb.CPBaddr = (UINT64)(UINTN) Cpb;
Snp->Cdb.StatCode = PXE_STATCODE_INITIALIZE;
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
index b124b72088..4923478954 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
@@ -1499,7 +1499,7 @@ ParseOpCodes (
CurrentStatement->Minimum = ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.MinValue;
CurrentStatement->Maximum = ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.MaxValue;
CurrentStatement->Step = ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.Step;
- CurrentStatement->StorageWidth = sizeof (UINT8);
+ CurrentStatement->StorageWidth = (UINT16) sizeof (UINT8);
Value->Type = EFI_IFR_TYPE_NUM_SIZE_8;
break;
@@ -1507,7 +1507,7 @@ ParseOpCodes (
CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.MinValue, sizeof (UINT16));
CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.MaxValue, sizeof (UINT16));
CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.Step, sizeof (UINT16));
- CurrentStatement->StorageWidth = sizeof (UINT16);
+ CurrentStatement->StorageWidth = (UINT16) sizeof (UINT16);
Value->Type = EFI_IFR_TYPE_NUM_SIZE_16;
break;
@@ -1515,7 +1515,7 @@ ParseOpCodes (
CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MinValue, sizeof (UINT32));
CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MaxValue, sizeof (UINT32));
CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.Step, sizeof (UINT32));
- CurrentStatement->StorageWidth = sizeof (UINT32);
+ CurrentStatement->StorageWidth = (UINT16) sizeof (UINT32);
Value->Type = EFI_IFR_TYPE_NUM_SIZE_32;
break;
@@ -1523,7 +1523,7 @@ ParseOpCodes (
CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u64.MinValue, sizeof (UINT64));
CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u64.MaxValue, sizeof (UINT64));
CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u64.Step, sizeof (UINT64));
- CurrentStatement->StorageWidth = sizeof (UINT64);
+ CurrentStatement->StorageWidth = (UINT16) sizeof (UINT64);
Value->Type = EFI_IFR_TYPE_NUM_SIZE_64;
break;
@@ -1558,7 +1558,7 @@ ParseOpCodes (
ASSERT(CurrentStatement != NULL);
CurrentStatement->Flags = ((EFI_IFR_CHECKBOX *) OpCodeData)->Flags;
- CurrentStatement->StorageWidth = sizeof (BOOLEAN);
+ CurrentStatement->StorageWidth = (UINT16) sizeof (BOOLEAN);
CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_BOOLEAN;
InitializeRequestElement (FormSet, CurrentStatement);
@@ -1610,7 +1610,7 @@ ParseOpCodes (
CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_DATE;
if ((CurrentStatement->Flags & EFI_QF_DATE_STORAGE) == QF_DATE_STORAGE_NORMAL) {
- CurrentStatement->StorageWidth = sizeof (EFI_HII_DATE);
+ CurrentStatement->StorageWidth = (UINT16) sizeof (EFI_HII_DATE);
InitializeRequestElement (FormSet, CurrentStatement);
} else {
@@ -1630,7 +1630,7 @@ ParseOpCodes (
CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_TIME;
if ((CurrentStatement->Flags & QF_TIME_STORAGE) == QF_TIME_STORAGE_NORMAL) {
- CurrentStatement->StorageWidth = sizeof (EFI_IFR_TIME);
+ CurrentStatement->StorageWidth = (UINT16) sizeof (EFI_IFR_TIME);
InitializeRequestElement (FormSet, CurrentStatement);
} else {
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c
index d916aeb8cf..3310bb284e 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c
@@ -1775,8 +1775,8 @@ UiDisplayMenu (
UpArrow = FALSE;
Row = TopRow;
- Temp = SkipValue;
- Temp2 = SkipValue;
+ Temp = (UINTN) SkipValue;
+ Temp2 = (UINTN) SkipValue;
ClearLines (
LocalScreen.LeftColumn,
@@ -2532,6 +2532,7 @@ UiDisplayMenu (
}
BufferSize = StrLen (StringPtr) / 2;
DevicePath = AllocatePool (BufferSize);
+ ASSERT (DevicePath != NULL);
//
// Convert from Device Path String to DevicePath Buffer in the reverse order.
@@ -2940,6 +2941,7 @@ UiDisplayMenu (
case CfUiPageDown:
ControlFlag = CfCheckSelection;
+ ASSERT (NewPos != NULL);
if (NewPos->ForwardLink == &gMenuOption) {
NewLine = FALSE;
Repaint = FALSE;
@@ -3007,7 +3009,7 @@ UiDisplayMenu (
//
// An option might be multi-line, so we need to reflect that data in the overall skip value
//
- UpdateOptionSkipLines (Selection, NextMenuOption, &OptionString, SkipValue);
+ UpdateOptionSkipLines (Selection, NextMenuOption, &OptionString, (UINTN) SkipValue);
Temp = MenuOption->Row + MenuOption->Skip + DistanceValue - 1;
if ((MenuOption->Row + MenuOption->Skip == BottomRow + 1) &&