mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-27 07:34:06 +02:00
MdePkg: CodeQL Fixes.
Includes changes across the repo for the following CodeQL rules: - cpp/comparison-with-wider-type - cpp/overflow-buffer - cpp/redundant-null-check-param - cpp/uselesstest Co-authored-by: Taylor Beebe <tabeebe@microsoft.com> Co-authored-by: kenlautner <85201046+kenlautner@users.noreply.github.com> Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
This commit is contained in:
parent
a9901a7748
commit
b7735a087a
@ -714,9 +714,7 @@ typedef struct {
|
||||
UINT16 DpaControl;
|
||||
UINT8 DpaPowerAllocationArray[1];
|
||||
} PCI_EXPRESS_EXTENDED_CAPABILITIES_DYNAMIC_POWER_ALLOCATION;
|
||||
|
||||
#define PCI_EXPRESS_EXTENDED_CAPABILITY_DYNAMIC_POWER_ALLOCATION_GET_SUBSTATE_MAX(POWER) (UINT16)(((POWER->DpaCapability)&0x0000000F))
|
||||
|
||||
#define PCI_EXPRESS_EXTENDED_CAPABILITY_DYNAMIC_POWER_ALLOCATION_GET_SUBSTATE_MAX(POWER) (UINT32)(((POWER->DpaCapability)&0x0000000F))
|
||||
#define PCI_EXPRESS_EXTENDED_CAPABILITY_LATENCE_TOLERANCE_REPORTING_ID 0x0018
|
||||
#define PCI_EXPRESS_EXTENDED_CAPABILITY_LATENCE_TOLERANCE_REPORTING_VER1 0x1
|
||||
|
||||
|
@ -407,9 +407,11 @@ StrDecimalToUintn (
|
||||
)
|
||||
{
|
||||
UINTN Result;
|
||||
RETURN_STATUS Status;
|
||||
|
||||
if (RETURN_ERROR (StrDecimalToUintnS (String, (CHAR16 **)NULL, &Result))) {
|
||||
return MAX_UINTN;
|
||||
Status = StrDecimalToUintnS (String, (CHAR16 **)NULL, &Result);
|
||||
if (Status == RETURN_INVALID_PARAMETER) {
|
||||
Result = 0;
|
||||
}
|
||||
|
||||
return Result;
|
||||
@ -456,9 +458,11 @@ StrDecimalToUint64 (
|
||||
)
|
||||
{
|
||||
UINT64 Result;
|
||||
RETURN_STATUS Status;
|
||||
|
||||
if (RETURN_ERROR (StrDecimalToUint64S (String, (CHAR16 **)NULL, &Result))) {
|
||||
return MAX_UINT64;
|
||||
Status = StrDecimalToUint64S (String, (CHAR16 **)NULL, &Result);
|
||||
if (Status == RETURN_INVALID_PARAMETER) {
|
||||
Result = 0;
|
||||
}
|
||||
|
||||
return Result;
|
||||
@ -506,9 +510,11 @@ StrHexToUintn (
|
||||
)
|
||||
{
|
||||
UINTN Result;
|
||||
RETURN_STATUS Status;
|
||||
|
||||
if (RETURN_ERROR (StrHexToUintnS (String, (CHAR16 **)NULL, &Result))) {
|
||||
return MAX_UINTN;
|
||||
Status = StrHexToUintnS (String, (CHAR16 **)NULL, &Result);
|
||||
if (Status == RETURN_INVALID_PARAMETER) {
|
||||
Result = 0;
|
||||
}
|
||||
|
||||
return Result;
|
||||
@ -556,9 +562,11 @@ StrHexToUint64 (
|
||||
)
|
||||
{
|
||||
UINT64 Result;
|
||||
RETURN_STATUS Status;
|
||||
|
||||
if (RETURN_ERROR (StrHexToUint64S (String, (CHAR16 **)NULL, &Result))) {
|
||||
return MAX_UINT64;
|
||||
Status = StrHexToUint64S (String, (CHAR16 **)NULL, &Result);
|
||||
if (Status == RETURN_INVALID_PARAMETER) {
|
||||
Result = 0;
|
||||
}
|
||||
|
||||
return Result;
|
||||
@ -1000,9 +1008,11 @@ AsciiStrDecimalToUintn (
|
||||
)
|
||||
{
|
||||
UINTN Result;
|
||||
RETURN_STATUS Status;
|
||||
|
||||
if (RETURN_ERROR (AsciiStrDecimalToUintnS (String, (CHAR8 **)NULL, &Result))) {
|
||||
return MAX_UINTN;
|
||||
Status = AsciiStrDecimalToUintnS (String, (CHAR8 **)NULL, &Result);
|
||||
if (Status == RETURN_INVALID_PARAMETER) {
|
||||
Result = 0;
|
||||
}
|
||||
|
||||
return Result;
|
||||
@ -1045,9 +1055,11 @@ AsciiStrDecimalToUint64 (
|
||||
)
|
||||
{
|
||||
UINT64 Result;
|
||||
RETURN_STATUS Status;
|
||||
|
||||
if (RETURN_ERROR (AsciiStrDecimalToUint64S (String, (CHAR8 **)NULL, &Result))) {
|
||||
return MAX_UINT64;
|
||||
Status = AsciiStrDecimalToUint64S (String, (CHAR8 **)NULL, &Result);
|
||||
if (Status == RETURN_INVALID_PARAMETER) {
|
||||
Result = 0;
|
||||
}
|
||||
|
||||
return Result;
|
||||
@ -1094,9 +1106,11 @@ AsciiStrHexToUintn (
|
||||
)
|
||||
{
|
||||
UINTN Result;
|
||||
RETURN_STATUS Status;
|
||||
|
||||
if (RETURN_ERROR (AsciiStrHexToUintnS (String, (CHAR8 **)NULL, &Result))) {
|
||||
return MAX_UINTN;
|
||||
Status = AsciiStrHexToUintnS (String, (CHAR8 **)NULL, &Result);
|
||||
if (Status == RETURN_INVALID_PARAMETER) {
|
||||
Result = 0;
|
||||
}
|
||||
|
||||
return Result;
|
||||
@ -1143,9 +1157,11 @@ AsciiStrHexToUint64 (
|
||||
)
|
||||
{
|
||||
UINT64 Result;
|
||||
RETURN_STATUS Status;
|
||||
|
||||
if (RETURN_ERROR (AsciiStrHexToUint64S (String, (CHAR8 **)NULL, &Result))) {
|
||||
return MAX_UINT64;
|
||||
Status = AsciiStrHexToUint64S (String, (CHAR8 **)NULL, &Result);
|
||||
if (Status == RETURN_INVALID_PARAMETER) {
|
||||
Result = 0;
|
||||
}
|
||||
|
||||
return Result;
|
||||
|
@ -68,7 +68,7 @@ PeCoffLoaderGetPeHeader (
|
||||
UINTN Size;
|
||||
UINTN ReadSize;
|
||||
UINT32 SectionHeaderOffset;
|
||||
UINT32 Index;
|
||||
UINTN Index;
|
||||
UINT32 HeaderWithoutDataDir;
|
||||
CHAR8 BufferData;
|
||||
UINTN NumberOfSections;
|
||||
@ -1407,7 +1407,7 @@ PeCoffLoaderLoadImage (
|
||||
return RETURN_LOAD_ERROR;
|
||||
}
|
||||
|
||||
if (Section->SizeOfRawData > 0) {
|
||||
if ((Section->SizeOfRawData > 0) && (Base != NULL)) {
|
||||
Status = ImageContext->ImageRead (
|
||||
ImageContext->Handle,
|
||||
Section->PointerToRawData - TeStrippedOffset,
|
||||
@ -1424,7 +1424,7 @@ PeCoffLoaderLoadImage (
|
||||
// If raw size is less then virtual size, zero fill the remaining
|
||||
//
|
||||
|
||||
if (Size < Section->Misc.VirtualSize) {
|
||||
if ((Size < Section->Misc.VirtualSize) && (Base != NULL)) {
|
||||
ZeroMem (Base + Size, Section->Misc.VirtualSize - Size);
|
||||
}
|
||||
|
||||
|
@ -685,7 +685,11 @@ InternalPeiServicesInstallFvInfoPpi (
|
||||
}
|
||||
|
||||
FvInfoPpiDescriptor = AllocatePool (sizeof (EFI_PEI_PPI_DESCRIPTOR));
|
||||
if (FvInfoPpiDescriptor == NULL) {
|
||||
ASSERT (FvInfoPpiDescriptor != NULL);
|
||||
// Need to return here, FV may not be published, but we are out of resources anyway...
|
||||
return;
|
||||
}
|
||||
|
||||
FvInfoPpiDescriptor->Guid = PpiGuid;
|
||||
FvInfoPpiDescriptor->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
|
||||
|
@ -269,14 +269,14 @@ IsHexStr (
|
||||
//
|
||||
// skip preceeding white space
|
||||
//
|
||||
while ((*Str != 0) && *Str == L' ') {
|
||||
while (*Str == L' ') {
|
||||
Str++;
|
||||
}
|
||||
|
||||
//
|
||||
// skip preceeding zeros
|
||||
//
|
||||
while ((*Str != 0) && *Str == L'0') {
|
||||
while (*Str == L'0') {
|
||||
Str++;
|
||||
}
|
||||
|
||||
@ -388,7 +388,10 @@ DevPathFromTextGenericPath (
|
||||
(UINT16)(sizeof (EFI_DEVICE_PATH_PROTOCOL) + DataLength)
|
||||
);
|
||||
|
||||
if (Node != NULL) {
|
||||
StrHexToBytes (DataStr, DataLength * 2, (UINT8 *)(Node + 1), DataLength);
|
||||
}
|
||||
|
||||
return Node;
|
||||
}
|
||||
|
||||
@ -453,8 +456,10 @@ DevPathFromTextPci (
|
||||
(UINT16)sizeof (PCI_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Pci != NULL) {
|
||||
Pci->Function = (UINT8)Strtoi (FunctionStr);
|
||||
Pci->Device = (UINT8)Strtoi (DeviceStr);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Pci;
|
||||
}
|
||||
@ -482,7 +487,9 @@ DevPathFromTextPcCard (
|
||||
(UINT16)sizeof (PCCARD_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Pccard != NULL) {
|
||||
Pccard->FunctionNumber = (UINT8)Strtoi (FunctionNumberStr);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Pccard;
|
||||
}
|
||||
@ -514,9 +521,11 @@ DevPathFromTextMemoryMapped (
|
||||
(UINT16)sizeof (MEMMAP_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (MemMap != NULL) {
|
||||
MemMap->MemoryType = (UINT32)Strtoi (MemoryTypeStr);
|
||||
Strtoi64 (StartingAddressStr, &MemMap->StartingAddress);
|
||||
Strtoi64 (EndingAddressStr, &MemMap->EndingAddress);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)MemMap;
|
||||
}
|
||||
@ -559,8 +568,10 @@ ConvertFromTextVendor (
|
||||
(UINT16)(sizeof (VENDOR_DEVICE_PATH) + Length)
|
||||
);
|
||||
|
||||
if (Vendor != NULL) {
|
||||
StrToGuid (GuidStr, &Vendor->Guid);
|
||||
StrHexToBytes (DataStr, Length * 2, (UINT8 *)(Vendor + 1), Length);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
|
||||
}
|
||||
@ -607,7 +618,10 @@ DevPathFromTextCtrl (
|
||||
HW_CONTROLLER_DP,
|
||||
(UINT16)sizeof (CONTROLLER_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Controller != NULL) {
|
||||
Controller->ControllerNumber = (UINT32)Strtoi (ControllerStr);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Controller;
|
||||
}
|
||||
@ -637,11 +651,13 @@ DevPathFromTextBmc (
|
||||
(UINT16)sizeof (BMC_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (BmcDp != NULL) {
|
||||
BmcDp->InterfaceType = (UINT8)Strtoi (InterfaceTypeStr);
|
||||
WriteUnaligned64 (
|
||||
(UINT64 *)(&BmcDp->BaseAddress),
|
||||
StrHexToUint64 (BaseAddressStr)
|
||||
);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)BmcDp;
|
||||
}
|
||||
@ -706,8 +722,10 @@ DevPathFromTextAcpi (
|
||||
(UINT16)sizeof (ACPI_HID_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Acpi != NULL) {
|
||||
Acpi->HID = EisaIdFromText (HIDStr);
|
||||
Acpi->UID = (UINT32)Strtoi (UIDStr);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Acpi;
|
||||
}
|
||||
@ -737,8 +755,10 @@ ConvertFromTextAcpi (
|
||||
(UINT16)sizeof (ACPI_HID_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Acpi != NULL) {
|
||||
Acpi->HID = EFI_PNP_ID (PnPId);
|
||||
Acpi->UID = (UINT32)Strtoi (UIDStr);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Acpi;
|
||||
}
|
||||
@ -878,6 +898,7 @@ DevPathFromTextAcpiEx (
|
||||
Length
|
||||
);
|
||||
|
||||
if (AcpiEx != NULL) {
|
||||
AcpiEx->HID = EisaIdFromText (HIDStr);
|
||||
AcpiEx->CID = EisaIdFromText (CIDStr);
|
||||
AcpiEx->UID = (UINT32)Strtoi (UIDStr);
|
||||
@ -886,6 +907,7 @@ DevPathFromTextAcpiEx (
|
||||
StrToAscii (HIDSTRStr, &AsciiStr);
|
||||
StrToAscii (UIDSTRStr, &AsciiStr);
|
||||
StrToAscii (CIDSTRStr, &AsciiStr);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)AcpiEx;
|
||||
}
|
||||
@ -920,6 +942,10 @@ DevPathFromTextAcpiExp (
|
||||
Length
|
||||
);
|
||||
|
||||
if (AcpiEx == NULL) {
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)AcpiEx;
|
||||
}
|
||||
|
||||
AcpiEx->HID = EisaIdFromText (HIDStr);
|
||||
//
|
||||
// According to UEFI spec, the CID parameter is optional and has a default value of 0.
|
||||
@ -975,7 +1001,10 @@ DevPathFromTextAcpiAdr (
|
||||
ACPI_ADR_DP,
|
||||
(UINT16)sizeof (ACPI_ADR_DEVICE_PATH)
|
||||
);
|
||||
if (AcpiAdr == NULL) {
|
||||
ASSERT (AcpiAdr != NULL);
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)AcpiAdr;
|
||||
}
|
||||
|
||||
for (Index = 0; ; Index++) {
|
||||
DisplayDeviceStr = GetNextParamStr (&TextDeviceNode);
|
||||
@ -990,7 +1019,12 @@ DevPathFromTextAcpiAdr (
|
||||
Length + sizeof (UINT32),
|
||||
AcpiAdr
|
||||
);
|
||||
|
||||
if (AcpiAdr == NULL) {
|
||||
ASSERT (AcpiAdr != NULL);
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)AcpiAdr;
|
||||
}
|
||||
|
||||
SetDevicePathNodeLength (AcpiAdr, Length + sizeof (UINT32));
|
||||
}
|
||||
|
||||
@ -1040,6 +1074,10 @@ DevPathFromTextAta (
|
||||
(UINT16)sizeof (ATAPI_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Atapi == NULL) {
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Atapi;
|
||||
}
|
||||
|
||||
PrimarySecondaryStr = GetNextParamStr (&TextDeviceNode);
|
||||
SlaveMasterStr = GetNextParamStr (&TextDeviceNode);
|
||||
LunStr = GetNextParamStr (&TextDeviceNode);
|
||||
@ -1090,8 +1128,10 @@ DevPathFromTextScsi (
|
||||
(UINT16)sizeof (SCSI_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Scsi != NULL) {
|
||||
Scsi->Pun = (UINT16)Strtoi (PunStr);
|
||||
Scsi->Lun = (UINT16)Strtoi (LunStr);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Scsi;
|
||||
}
|
||||
@ -1121,9 +1161,11 @@ DevPathFromTextFibre (
|
||||
(UINT16)sizeof (FIBRECHANNEL_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Fibre != NULL) {
|
||||
Fibre->Reserved = 0;
|
||||
Strtoi64 (WWNStr, &Fibre->WWN);
|
||||
Strtoi64 (LunStr, &Fibre->Lun);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Fibre;
|
||||
}
|
||||
@ -1153,12 +1195,14 @@ DevPathFromTextFibreEx (
|
||||
(UINT16)sizeof (FIBRECHANNELEX_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (FibreEx != NULL) {
|
||||
FibreEx->Reserved = 0;
|
||||
Strtoi64 (WWNStr, (UINT64 *)(&FibreEx->WWN));
|
||||
Strtoi64 (LunStr, (UINT64 *)(&FibreEx->Lun));
|
||||
|
||||
*(UINT64 *)(&FibreEx->WWN) = SwapBytes64 (*(UINT64 *)(&FibreEx->WWN));
|
||||
*(UINT64 *)(&FibreEx->Lun) = SwapBytes64 (*(UINT64 *)(&FibreEx->Lun));
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)FibreEx;
|
||||
}
|
||||
@ -1186,8 +1230,10 @@ DevPathFromText1394 (
|
||||
(UINT16)sizeof (F1394_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (F1394DevPath != NULL) {
|
||||
F1394DevPath->Reserved = 0;
|
||||
F1394DevPath->Guid = StrHexToUint64 (GuidStr);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)F1394DevPath;
|
||||
}
|
||||
@ -1217,8 +1263,10 @@ DevPathFromTextUsb (
|
||||
(UINT16)sizeof (USB_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Usb != NULL) {
|
||||
Usb->ParentPortNumber = (UINT8)Strtoi (PortStr);
|
||||
Usb->InterfaceNumber = (UINT8)Strtoi (InterfaceStr);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Usb;
|
||||
}
|
||||
@ -1246,7 +1294,9 @@ DevPathFromTextI2O (
|
||||
(UINT16)sizeof (I2O_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (I2ODevPath != NULL) {
|
||||
I2ODevPath->Tid = (UINT32)Strtoi (TIDStr);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)I2ODevPath;
|
||||
}
|
||||
@ -1282,11 +1332,13 @@ DevPathFromTextInfiniband (
|
||||
(UINT16)sizeof (INFINIBAND_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (InfiniBand != NULL) {
|
||||
InfiniBand->ResourceFlags = (UINT32)Strtoi (FlagsStr);
|
||||
StrToGuid (GuidStr, (EFI_GUID *)InfiniBand->PortGid);
|
||||
Strtoi64 (SidStr, &InfiniBand->ServiceId);
|
||||
Strtoi64 (TidStr, &InfiniBand->TargetPortId);
|
||||
Strtoi64 (DidStr, &InfiniBand->DeviceId);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)InfiniBand;
|
||||
}
|
||||
@ -1331,7 +1383,10 @@ DevPathFromTextVenPcAnsi (
|
||||
MSG_VENDOR_DP,
|
||||
(UINT16)sizeof (VENDOR_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Vendor != NULL) {
|
||||
CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
|
||||
}
|
||||
@ -1356,7 +1411,10 @@ DevPathFromTextVenVt100 (
|
||||
MSG_VENDOR_DP,
|
||||
(UINT16)sizeof (VENDOR_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Vendor != NULL) {
|
||||
CopyGuid (&Vendor->Guid, &gEfiVT100Guid);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
|
||||
}
|
||||
@ -1381,7 +1439,10 @@ DevPathFromTextVenVt100Plus (
|
||||
MSG_VENDOR_DP,
|
||||
(UINT16)sizeof (VENDOR_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Vendor != NULL) {
|
||||
CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
|
||||
}
|
||||
@ -1406,7 +1467,10 @@ DevPathFromTextVenUtf8 (
|
||||
MSG_VENDOR_DP,
|
||||
(UINT16)sizeof (VENDOR_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Vendor != NULL) {
|
||||
CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
|
||||
}
|
||||
@ -1434,6 +1498,7 @@ DevPathFromTextUartFlowCtrl (
|
||||
(UINT16)sizeof (UART_FLOW_CONTROL_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (UartFlowControl != NULL) {
|
||||
CopyGuid (&UartFlowControl->Guid, &gEfiUartDevicePathGuid);
|
||||
if (StrCmp (ValueStr, L"XonXoff") == 0) {
|
||||
UartFlowControl->FlowControlMap = 2;
|
||||
@ -1442,6 +1507,7 @@ DevPathFromTextUartFlowCtrl (
|
||||
} else {
|
||||
UartFlowControl->FlowControlMap = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)UartFlowControl;
|
||||
}
|
||||
@ -1485,6 +1551,10 @@ DevPathFromTextSAS (
|
||||
(UINT16)sizeof (SAS_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Sas == NULL) {
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Sas;
|
||||
}
|
||||
|
||||
CopyGuid (&Sas->Guid, &gEfiSasDevicePathGuid);
|
||||
Strtoi64 (AddressStr, &Sas->SasAddress);
|
||||
Strtoi64 (LunStr, &Sas->Lun);
|
||||
@ -1580,6 +1650,10 @@ DevPathFromTextSasEx (
|
||||
(UINT16)sizeof (SASEX_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (SasEx == NULL) {
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)SasEx;
|
||||
}
|
||||
|
||||
Strtoi64 (AddressStr, &SasAddress);
|
||||
Strtoi64 (LunStr, &Lun);
|
||||
WriteUnaligned64 ((UINT64 *)&SasEx->SasAddress, SwapBytes64 (SasAddress));
|
||||
@ -1663,6 +1737,7 @@ DevPathFromTextNVMe (
|
||||
(UINT16)sizeof (NVME_NAMESPACE_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Nvme != NULL) {
|
||||
Nvme->NamespaceId = (UINT32)Strtoi (NamespaceIdStr);
|
||||
Uuid = (UINT8 *)&Nvme->NamespaceUuid;
|
||||
|
||||
@ -1670,6 +1745,7 @@ DevPathFromTextNVMe (
|
||||
while (Index-- != 0) {
|
||||
Uuid[Index] = (UINT8)StrHexToUintn (SplitStr (&NamespaceUuidStr, L'-'));
|
||||
}
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Nvme;
|
||||
}
|
||||
@ -1699,8 +1775,10 @@ DevPathFromTextUfs (
|
||||
(UINT16)sizeof (UFS_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Ufs != NULL) {
|
||||
Ufs->Pun = (UINT8)Strtoi (PunStr);
|
||||
Ufs->Lun = (UINT8)Strtoi (LunStr);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Ufs;
|
||||
}
|
||||
@ -1728,7 +1806,9 @@ DevPathFromTextSd (
|
||||
(UINT16)sizeof (SD_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Sd != NULL) {
|
||||
Sd->SlotNumber = (UINT8)Strtoi (SlotNumberStr);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Sd;
|
||||
}
|
||||
@ -1756,7 +1836,9 @@ DevPathFromTextEmmc (
|
||||
(UINT16)sizeof (EMMC_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Emmc != NULL) {
|
||||
Emmc->SlotNumber = (UINT8)Strtoi (SlotNumberStr);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Emmc;
|
||||
}
|
||||
@ -1782,7 +1864,9 @@ DevPathFromTextDebugPort (
|
||||
(UINT16)sizeof (VENDOR_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Vend != NULL) {
|
||||
CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Vend;
|
||||
}
|
||||
@ -1813,6 +1897,7 @@ DevPathFromTextMAC (
|
||||
(UINT16)sizeof (MAC_ADDR_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (MACDevPath != NULL) {
|
||||
MACDevPath->IfType = (UINT8)Strtoi (IfTypeStr);
|
||||
|
||||
Length = sizeof (EFI_MAC_ADDRESS);
|
||||
@ -1821,6 +1906,7 @@ DevPathFromTextMAC (
|
||||
}
|
||||
|
||||
StrHexToBytes (AddressStr, Length * 2, MACDevPath->MacAddress.Addr, Length);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)MACDevPath;
|
||||
}
|
||||
@ -1882,6 +1968,10 @@ DevPathFromTextIPv4 (
|
||||
(UINT16)sizeof (IPv4_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (IPv4 == NULL) {
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)IPv4;
|
||||
}
|
||||
|
||||
StrToIpv4Address (RemoteIPStr, NULL, &IPv4->RemoteIpAddress, NULL);
|
||||
IPv4->Protocol = (UINT16)NetworkProtocolFromText (ProtocolStr);
|
||||
if (StrCmp (TypeStr, L"Static") == 0) {
|
||||
@ -1938,6 +2028,10 @@ DevPathFromTextIPv6 (
|
||||
(UINT16)sizeof (IPv6_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (IPv6 == NULL) {
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)IPv6;
|
||||
}
|
||||
|
||||
StrToIpv6Address (RemoteIPStr, NULL, &IPv6->RemoteIpAddress, NULL);
|
||||
IPv6->Protocol = (UINT16)NetworkProtocolFromText (ProtocolStr);
|
||||
if (StrCmp (TypeStr, L"Static") == 0) {
|
||||
@ -1992,6 +2086,10 @@ DevPathFromTextUart (
|
||||
(UINT16)sizeof (UART_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Uart == NULL) {
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Uart;
|
||||
}
|
||||
|
||||
if (StrCmp (BaudStr, L"DEFAULT") == 0) {
|
||||
Uart->BaudRate = 115200;
|
||||
} else {
|
||||
@ -2072,6 +2170,10 @@ ConvertFromTextUsbClass (
|
||||
(UINT16)sizeof (USB_CLASS_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (UsbClass == NULL) {
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)UsbClass;
|
||||
}
|
||||
|
||||
VIDStr = GetNextParamStr (&TextDeviceNode);
|
||||
PIDStr = GetNextParamStr (&TextDeviceNode);
|
||||
if (UsbClassText->ClassExist) {
|
||||
@ -2513,6 +2615,8 @@ DevPathFromTextUsbWwid (
|
||||
MSG_USB_WWID_DP,
|
||||
(UINT16)(sizeof (USB_WWID_DEVICE_PATH) + SerialNumberStrLen * sizeof (CHAR16))
|
||||
);
|
||||
|
||||
if (UsbWwid != NULL) {
|
||||
UsbWwid->VendorId = (UINT16)Strtoi (VIDStr);
|
||||
UsbWwid->ProductId = (UINT16)Strtoi (PIDStr);
|
||||
UsbWwid->InterfaceNumber = (UINT16)Strtoi (InterfaceNumStr);
|
||||
@ -2526,6 +2630,7 @@ DevPathFromTextUsbWwid (
|
||||
SerialNumberStr,
|
||||
SerialNumberStrLen * sizeof (CHAR16)
|
||||
);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)UsbWwid;
|
||||
}
|
||||
@ -2553,7 +2658,9 @@ DevPathFromTextUnit (
|
||||
(UINT16)sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (LogicalUnit != NULL) {
|
||||
LogicalUnit->Lun = (UINT8)Strtoi (LunStr);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)LogicalUnit;
|
||||
}
|
||||
@ -2596,6 +2703,10 @@ DevPathFromTextiSCSI (
|
||||
(UINT16)(sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + StrLen (NameStr))
|
||||
);
|
||||
|
||||
if (ISCSIDevPath == NULL) {
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)ISCSIDevPath;
|
||||
}
|
||||
|
||||
AsciiStr = ISCSIDevPath->TargetName;
|
||||
StrToAscii (NameStr, &AsciiStr);
|
||||
|
||||
@ -2657,7 +2768,9 @@ DevPathFromTextVlan (
|
||||
(UINT16)sizeof (VLAN_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Vlan != NULL) {
|
||||
Vlan->VlanId = (UINT16)Strtoi (VlanStr);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Vlan;
|
||||
}
|
||||
@ -2684,12 +2797,16 @@ DevPathFromTextBluetooth (
|
||||
MSG_BLUETOOTH_DP,
|
||||
(UINT16)sizeof (BLUETOOTH_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (BluetoothDp != NULL) {
|
||||
StrHexToBytes (
|
||||
BluetoothStr,
|
||||
sizeof (BLUETOOTH_ADDRESS) * 2,
|
||||
BluetoothDp->BD_ADDR.Address,
|
||||
sizeof (BLUETOOTH_ADDRESS)
|
||||
);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)BluetoothDp;
|
||||
}
|
||||
|
||||
@ -2718,7 +2835,7 @@ DevPathFromTextWiFi (
|
||||
(UINT16)sizeof (WIFI_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (NULL != SSIdStr) {
|
||||
if ((NULL != SSIdStr) && (NULL != WiFiDp)) {
|
||||
DataLen = StrLen (SSIdStr);
|
||||
if (StrLen (SSIdStr) > 32) {
|
||||
SSIdStr[32] = L'\0';
|
||||
@ -2757,6 +2874,7 @@ DevPathFromTextBluetoothLE (
|
||||
(UINT16)sizeof (BLUETOOTH_LE_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (BluetoothLeDp != NULL) {
|
||||
BluetoothLeDp->Address.Type = (UINT8)Strtoi (BluetoothLeAddrTypeStr);
|
||||
StrHexToBytes (
|
||||
BluetoothLeAddrStr,
|
||||
@ -2764,6 +2882,8 @@ DevPathFromTextBluetoothLE (
|
||||
BluetoothLeDp->Address.Address,
|
||||
sizeof (BluetoothLeDp->Address.Address)
|
||||
);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)BluetoothLeDp;
|
||||
}
|
||||
|
||||
@ -2883,7 +3003,7 @@ DevPathFromTextUri (
|
||||
(UINT16)(sizeof (URI_DEVICE_PATH) + UriLength)
|
||||
);
|
||||
|
||||
while (UriLength-- != 0) {
|
||||
while (Uri != NULL && UriLength-- != 0) {
|
||||
Uri->Uri[UriLength] = (CHAR8)UriStr[UriLength];
|
||||
}
|
||||
|
||||
@ -2938,6 +3058,10 @@ DevPathFromTextHD (
|
||||
(UINT16)sizeof (HARDDRIVE_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Hd == NULL) {
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Hd;
|
||||
}
|
||||
|
||||
Hd->PartitionNumber = (UINT32)Strtoi (PartitionStr);
|
||||
|
||||
ZeroMem (Hd->Signature, 16);
|
||||
@ -2991,9 +3115,11 @@ DevPathFromTextCDROM (
|
||||
(UINT16)sizeof (CDROM_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (CDROMDevPath != NULL) {
|
||||
CDROMDevPath->BootEntry = (UINT32)Strtoi (EntryStr);
|
||||
Strtoi64 (StartStr, &CDROMDevPath->PartitionStart);
|
||||
Strtoi64 (SizeStr, &CDROMDevPath->PartitionSize);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)CDROMDevPath;
|
||||
}
|
||||
@ -3039,7 +3165,9 @@ DevPathFromTextFilePath (
|
||||
(UINT16)(sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) * 2)
|
||||
);
|
||||
|
||||
if (File != NULL) {
|
||||
StrCpyS (File->PathName, StrLen (TextDeviceNode) + 1, TextDeviceNode);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)File;
|
||||
}
|
||||
@ -3067,7 +3195,9 @@ DevPathFromTextMedia (
|
||||
(UINT16)sizeof (MEDIA_PROTOCOL_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Media != NULL) {
|
||||
StrToGuid (GuidStr, &Media->Protocol);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Media;
|
||||
}
|
||||
@ -3095,7 +3225,9 @@ DevPathFromTextFv (
|
||||
(UINT16)sizeof (MEDIA_FW_VOL_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Fv != NULL) {
|
||||
StrToGuid (GuidStr, &Fv->FvName);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Fv;
|
||||
}
|
||||
@ -3123,7 +3255,9 @@ DevPathFromTextFvFile (
|
||||
(UINT16)sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (FvFile != NULL) {
|
||||
StrToGuid (GuidStr, &FvFile->FvFileName);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)FvFile;
|
||||
}
|
||||
@ -3153,8 +3287,10 @@ DevPathFromTextRelativeOffsetRange (
|
||||
(UINT16)sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Offset != NULL) {
|
||||
Strtoi64 (StartingOffsetStr, &Offset->StartingOffset);
|
||||
Strtoi64 (EndingOffsetStr, &Offset->EndingOffset);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Offset;
|
||||
}
|
||||
@ -3190,12 +3326,14 @@ DevPathFromTextRamDisk (
|
||||
(UINT16)sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (RamDisk != NULL) {
|
||||
Strtoi64 (StartingAddrStr, &StartingAddr);
|
||||
WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
|
||||
Strtoi64 (EndingAddrStr, &EndingAddr);
|
||||
WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
|
||||
RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
|
||||
StrToGuid (TypeGuidStr, &RamDisk->TypeGuid);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)RamDisk;
|
||||
}
|
||||
@ -3230,12 +3368,14 @@ DevPathFromTextVirtualDisk (
|
||||
(UINT16)sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (RamDisk != NULL) {
|
||||
Strtoi64 (StartingAddrStr, &StartingAddr);
|
||||
WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
|
||||
Strtoi64 (EndingAddrStr, &EndingAddr);
|
||||
WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
|
||||
RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
|
||||
CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualDiskGuid);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)RamDisk;
|
||||
}
|
||||
@ -3270,12 +3410,14 @@ DevPathFromTextVirtualCd (
|
||||
(UINT16)sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (RamDisk != NULL) {
|
||||
Strtoi64 (StartingAddrStr, &StartingAddr);
|
||||
WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
|
||||
Strtoi64 (EndingAddrStr, &EndingAddr);
|
||||
WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
|
||||
RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
|
||||
CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualCdGuid);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)RamDisk;
|
||||
}
|
||||
@ -3310,12 +3452,14 @@ DevPathFromTextPersistentVirtualDisk (
|
||||
(UINT16)sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (RamDisk != NULL) {
|
||||
Strtoi64 (StartingAddrStr, &StartingAddr);
|
||||
WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
|
||||
Strtoi64 (EndingAddrStr, &EndingAddr);
|
||||
WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
|
||||
RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
|
||||
CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualDiskGuid);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)RamDisk;
|
||||
}
|
||||
@ -3350,12 +3494,14 @@ DevPathFromTextPersistentVirtualCd (
|
||||
(UINT16)sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (RamDisk != NULL) {
|
||||
Strtoi64 (StartingAddrStr, &StartingAddr);
|
||||
WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
|
||||
Strtoi64 (EndingAddrStr, &EndingAddr);
|
||||
WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
|
||||
RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
|
||||
CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualCdGuid);
|
||||
}
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)RamDisk;
|
||||
}
|
||||
@ -3404,6 +3550,10 @@ DevPathFromTextBBS (
|
||||
(UINT16)(sizeof (BBS_BBS_DEVICE_PATH) + StrLen (IdStr))
|
||||
);
|
||||
|
||||
if (Bbs == NULL) {
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Bbs;
|
||||
}
|
||||
|
||||
if (StrCmp (TypeStr, L"Floppy") == 0) {
|
||||
Bbs->DeviceType = BBS_TYPE_FLOPPY;
|
||||
} else if (StrCmp (TypeStr, L"HD") == 0) {
|
||||
@ -3455,6 +3605,11 @@ DevPathFromTextSata (
|
||||
MSG_SATA_DP,
|
||||
(UINT16)sizeof (SATA_DEVICE_PATH)
|
||||
);
|
||||
|
||||
if (Sata == NULL) {
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Sata;
|
||||
}
|
||||
|
||||
Sata->HBAPortNumber = (UINT16)Strtoi (Param1);
|
||||
|
||||
//
|
||||
@ -3652,29 +3807,54 @@ UefiDevicePathLibConvertTextToDevicePath (
|
||||
}
|
||||
|
||||
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)AllocatePool (END_DEVICE_PATH_LENGTH);
|
||||
|
||||
if (DevicePath == NULL) {
|
||||
ASSERT (DevicePath != NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SetDevicePathEndNode (DevicePath);
|
||||
|
||||
DevicePathStr = UefiDevicePathLibStrDuplicate (TextDevicePath);
|
||||
|
||||
if (DevicePathStr == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Str = DevicePathStr;
|
||||
while ((DeviceNodeStr = GetNextDeviceNodeStr (&Str, &IsInstanceEnd)) != NULL) {
|
||||
DeviceNode = UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr);
|
||||
|
||||
NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);
|
||||
if (DevicePath != NULL) {
|
||||
FreePool (DevicePath);
|
||||
}
|
||||
|
||||
if (DeviceNode != NULL) {
|
||||
FreePool (DeviceNode);
|
||||
}
|
||||
|
||||
DevicePath = NewDevicePath;
|
||||
|
||||
if (IsInstanceEnd) {
|
||||
DeviceNode = (EFI_DEVICE_PATH_PROTOCOL *)AllocatePool (END_DEVICE_PATH_LENGTH);
|
||||
if (DeviceNode == NULL) {
|
||||
ASSERT (DeviceNode != NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SetDevicePathEndNode (DeviceNode);
|
||||
DeviceNode->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;
|
||||
|
||||
NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);
|
||||
if (DevicePath != NULL) {
|
||||
FreePool (DevicePath);
|
||||
}
|
||||
|
||||
if (DeviceNode != NULL) {
|
||||
FreePool (DeviceNode);
|
||||
}
|
||||
|
||||
DevicePath = NewDevicePath;
|
||||
}
|
||||
}
|
||||
|
@ -1842,7 +1842,11 @@ DevPathToTextUri (
|
||||
Uri = DevPath;
|
||||
UriLength = DevicePathNodeLength (Uri) - sizeof (URI_DEVICE_PATH);
|
||||
UriStr = AllocatePool (UriLength + 1);
|
||||
|
||||
if (UriStr == NULL) {
|
||||
ASSERT (UriStr != NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
CopyMem (UriStr, Uri->Uri, UriLength);
|
||||
UriStr[UriLength] = '\0';
|
||||
|
@ -930,6 +930,11 @@ FileHandleReturnLine (
|
||||
Status = FileHandleReadLine (Handle, RetVal, &Size, FALSE, Ascii);
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
RetVal = AllocateZeroPool (Size);
|
||||
|
||||
if (RetVal == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Status = FileHandleReadLine (Handle, RetVal, &Size, FALSE, Ascii);
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,12 @@ LocateAcpiTableInAcpiConfigurationTable (
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (Fadt != NULL) {
|
||||
Table = LocateAcpiDsdtFromFadt (Fadt);
|
||||
} else {
|
||||
Table = NULL;
|
||||
}
|
||||
} else if (Signature == EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE) {
|
||||
ASSERT (PreviousTable == NULL);
|
||||
//
|
||||
@ -234,7 +239,12 @@ LocateAcpiTableInAcpiConfigurationTable (
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (Fadt != NULL) {
|
||||
Table = LocateAcpiFacsFromFadt (Fadt);
|
||||
} else {
|
||||
Table = NULL;
|
||||
}
|
||||
} else {
|
||||
Table = ScanTableInSDT (
|
||||
Xsdt,
|
||||
@ -275,7 +285,12 @@ LocateAcpiTableInAcpiConfigurationTable (
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (Fadt != NULL) {
|
||||
Table = LocateAcpiDsdtFromFadt (Fadt);
|
||||
} else {
|
||||
Table = NULL;
|
||||
}
|
||||
} else if (Signature == EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE) {
|
||||
ASSERT (PreviousTable == NULL);
|
||||
//
|
||||
@ -289,7 +304,12 @@ LocateAcpiTableInAcpiConfigurationTable (
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (Fadt != NULL) {
|
||||
Table = LocateAcpiFacsFromFadt (Fadt);
|
||||
} else {
|
||||
Table = NULL;
|
||||
}
|
||||
} else {
|
||||
Table = ScanTableInSDT (
|
||||
Rsdt,
|
||||
|
@ -477,7 +477,11 @@ CreatePopUp (
|
||||
// Allocate a buffer for a single line of the popup with borders and a Null-terminator
|
||||
//
|
||||
Line = AllocateZeroPool ((MaxLength + 3) * sizeof (CHAR16));
|
||||
|
||||
if (Line == NULL) {
|
||||
ASSERT (Line != NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Draw top of popup box
|
||||
@ -513,7 +517,12 @@ CreatePopUp (
|
||||
//
|
||||
UefiLibGetStringWidth (String, TRUE, MaxLength, &Length);
|
||||
TmpString = AllocateZeroPool ((Length + 1) * sizeof (CHAR16));
|
||||
|
||||
if (TmpString == NULL) {
|
||||
ASSERT (TmpString != NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
StrnCpyS (TmpString, Length + 1, String, Length - 3);
|
||||
StrCatS (TmpString, Length + 1, L"...");
|
||||
|
||||
|
@ -65,7 +65,11 @@ InternalPrint (
|
||||
BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);
|
||||
|
||||
Buffer = (CHAR16 *)AllocatePool (BufferSize);
|
||||
|
||||
if (Buffer == NULL) {
|
||||
ASSERT (Buffer != NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);
|
||||
|
||||
@ -199,7 +203,11 @@ AsciiInternalPrint (
|
||||
BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);
|
||||
|
||||
Buffer = (CHAR16 *)AllocatePool (BufferSize);
|
||||
|
||||
if (Buffer == NULL) {
|
||||
ASSERT (Buffer != NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Return = UnicodeVSPrintAsciiFormat (Buffer, BufferSize, Format, Marker);
|
||||
|
||||
@ -419,7 +427,11 @@ InternalPrintGraphic (
|
||||
}
|
||||
|
||||
Blt = (EFI_IMAGE_OUTPUT *)AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));
|
||||
|
||||
if (Blt == NULL) {
|
||||
ASSERT (Blt != NULL);
|
||||
goto Error;
|
||||
}
|
||||
|
||||
Blt->Width = (UINT16)(HorizontalResolution);
|
||||
Blt->Height = (UINT16)(VerticalResolution);
|
||||
@ -625,7 +637,11 @@ PrintXY (
|
||||
BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);
|
||||
|
||||
Buffer = (CHAR16 *)AllocatePool (BufferSize);
|
||||
|
||||
if (Buffer == NULL) {
|
||||
ASSERT (Buffer != NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
PrintNum = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);
|
||||
|
||||
@ -703,7 +719,11 @@ AsciiPrintXY (
|
||||
BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);
|
||||
|
||||
Buffer = (CHAR16 *)AllocatePool (BufferSize);
|
||||
|
||||
if (Buffer == NULL) {
|
||||
ASSERT (Buffer != NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
PrintNum = UnicodeSPrintAsciiFormat (Buffer, BufferSize, Format, Marker);
|
||||
|
||||
|
@ -184,7 +184,11 @@ DxePciSegmentLibPciRootBridgeIoReadWorker (
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
|
||||
|
||||
PciRootBridgeIo = PciSegmentLibSearchForRootBridge (Address);
|
||||
|
||||
if (PciRootBridgeIo == NULL) {
|
||||
ASSERT (PciRootBridgeIo != NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
PciRootBridgeIo->Pci.Read (
|
||||
PciRootBridgeIo,
|
||||
@ -223,7 +227,11 @@ DxePciSegmentLibPciRootBridgeIoWriteWorker (
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
|
||||
|
||||
PciRootBridgeIo = PciSegmentLibSearchForRootBridge (Address);
|
||||
|
||||
if (PciRootBridgeIo == NULL) {
|
||||
ASSERT (PciRootBridgeIo != NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
PciRootBridgeIo->Pci.Write (
|
||||
PciRootBridgeIo,
|
||||
|
Loading…
x
Reference in New Issue
Block a user