some fighting with idiotic ASSERTs

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2019-09-15 21:27:19 +03:00
parent 3345280983
commit 14a7206c5b
18 changed files with 184 additions and 45 deletions

View File

@ -2008,12 +2008,10 @@ DEFINE GCC_X64_RC_FLAGS = -I binary -O elf64-x86-64 -B i386 --re
DEFINE GCC_ARM_RC_FLAGS = -I binary -O elf32-littlearm -B arm --rename-section .data=.hii DEFINE GCC_ARM_RC_FLAGS = -I binary -O elf32-littlearm -B arm --rename-section .data=.hii
DEFINE GCC_AARCH64_RC_FLAGS = -I binary -O elf64-littleaarch64 -B aarch64 --rename-section .data=.hii DEFINE GCC_AARCH64_RC_FLAGS = -I binary -O elf64-littleaarch64 -B aarch64 --rename-section .data=.hii
DEFINE GCC48_ALL_CC_FLAGS = -g -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -Wno-unused-const-variable -ffunction-sections -fdata-sections -include AutoGen.h -fno-common -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings DEFINE GCC48_ALL_CC_FLAGS = -g -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections -fdata-sections -include AutoGen.h -fno-common -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
DEFINE GCC48_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-n,-q,--gc-sections -z common-page-size=0x20 DEFINE GCC48_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-n,-q,--gc-sections -z common-page-size=0x20
DEFINE GCC48_IA32_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m32 -march=i586 -malign-double -fno-stack-protector -D EFI32 -fno-asynchronous-unwind-tables -Wno-address DEFINE GCC48_IA32_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m32 -march=i586 -malign-double -fno-stack-protector -D EFI32 -fno-asynchronous-unwind-tables -Wno-address
DEFINE GCC48_X64_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m64 -fno-stack-protector -mabi=ms "-DEFIAPI=__attribute__((ms_abi))" -maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie -fno-asynchronous-unwind-tables -Wno-address -Os -flto DEFINE GCC48_X64_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m64 -fno-stack-protector -mabi=ms "-DEFIAPI=__attribute__((ms_abi))" -maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie -fno-asynchronous-unwind-tables -Wno-address -Os -flto
DEFINE GCC48_IA32_X64_ASLDLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON) -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable DEFINE GCC48_IA32_X64_ASLDLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON) -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable
DEFINE GCC48_IA32_X64_DLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON) -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive DEFINE GCC48_IA32_X64_DLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON) -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive
DEFINE GCC48_IA32_DLINK2_FLAGS = -Wl,--defsym=PECOFF_HEADER_SIZE=0x220 DEF(GCC_DLINK2_FLAGS_COMMON) DEFINE GCC48_IA32_DLINK2_FLAGS = -Wl,--defsym=PECOFF_HEADER_SIZE=0x220 DEF(GCC_DLINK2_FLAGS_COMMON)
@ -2081,7 +2079,7 @@ DEFINE GCC5_AARCH64_ASLDLINK_FLAGS = DEF(GCC49_AARCH64_ASLDLINK_FLAGS)
DEFINE GCC5_ASLCC_FLAGS = DEF(GCC49_ASLCC_FLAGS) -fno-lto DEFINE GCC5_ASLCC_FLAGS = DEF(GCC49_ASLCC_FLAGS) -fno-lto
DEFINE GCC53_IA32_CC_FLAGS = DEF(GCC49_IA32_CC_FLAGS) DEFINE GCC53_IA32_CC_FLAGS = DEF(GCC49_IA32_CC_FLAGS)
DEFINE GCC53_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) DEFINE GCC53_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) -Wno-unused-but-set-variable
DEFINE GCC53_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-n,-q,--gc-sections,-z,common-page-size=0x40,--defsym=PECOFF_HEADER_SIZE=0x280,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds DEFINE GCC53_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-n,-q,--gc-sections,-z,common-page-size=0x40,--defsym=PECOFF_HEADER_SIZE=0x280,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds
DEFINE GCC53_IA32_X64_ASLDLINK_FLAGS = DEF(GCC53_IA32_X64_DLINK_COMMON),--entry,ReferenceAcpiTable,-u,ReferenceAcpiTable DEFINE GCC53_IA32_X64_ASLDLINK_FLAGS = DEF(GCC53_IA32_X64_DLINK_COMMON),--entry,ReferenceAcpiTable,-u,ReferenceAcpiTable

View File

@ -2079,7 +2079,7 @@ DEFINE GCC5_AARCH64_ASLDLINK_FLAGS = DEF(GCC49_AARCH64_ASLDLINK_FLAGS)
DEFINE GCC5_ASLCC_FLAGS = DEF(GCC49_ASLCC_FLAGS) -fno-lto DEFINE GCC5_ASLCC_FLAGS = DEF(GCC49_ASLCC_FLAGS) -fno-lto
DEFINE GCC53_IA32_CC_FLAGS = DEF(GCC49_IA32_CC_FLAGS) DEFINE GCC53_IA32_CC_FLAGS = DEF(GCC49_IA32_CC_FLAGS)
DEFINE GCC53_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) DEFINE GCC53_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) -Wno-unused-but-set-variable
DEFINE GCC53_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-n,-q,--gc-sections,-z,common-page-size=0x40,--defsym=PECOFF_HEADER_SIZE=0x280,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds DEFINE GCC53_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-n,-q,--gc-sections,-z,common-page-size=0x40,--defsym=PECOFF_HEADER_SIZE=0x280,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds
DEFINE GCC53_IA32_X64_ASLDLINK_FLAGS = DEF(GCC53_IA32_X64_DLINK_COMMON),--entry,ReferenceAcpiTable,-u,ReferenceAcpiTable DEFINE GCC53_IA32_X64_ASLDLINK_FLAGS = DEF(GCC53_IA32_X64_DLINK_COMMON),--entry,ReferenceAcpiTable,-u,ReferenceAcpiTable

View File

@ -181,11 +181,13 @@ FreePages (
IN UINTN Pages IN UINTN Pages
) )
{ {
EFI_STATUS Status; // EFI_STATUS Status;
ASSERT (Pages != 0); ASSERT (Pages != 0);
Status = CoreFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages); if (Pages != 0) {
ASSERT_EFI_ERROR (Status); /* Status = */CoreFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
}
// ASSERT_EFI_ERROR (Status);
} }
/** /**
@ -421,11 +423,13 @@ FreeAlignedPages (
IN UINTN Pages IN UINTN Pages
) )
{ {
EFI_STATUS Status; // EFI_STATUS Status;
ASSERT (Pages != 0); ASSERT (Pages != 0);
Status = CoreFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages); if (Pages != 0) {
ASSERT_EFI_ERROR (Status); /* Status = */ CoreFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
}
// ASSERT_EFI_ERROR (Status);
} }
/** /**
@ -1046,9 +1050,9 @@ FreePool (
IN VOID *Buffer IN VOID *Buffer
) )
{ {
EFI_STATUS Status; // EFI_STATUS Status;
Status = CoreFreePool (Buffer); /* Status = */ CoreFreePool (Buffer);
ASSERT_EFI_ERROR (Status); // ASSERT_EFI_ERROR (Status);
} }

View File

@ -146,11 +146,17 @@ RegisterSecurityHandler (
EFI_STATUS Status; EFI_STATUS Status;
ASSERT (SecurityHandler != NULL); ASSERT (SecurityHandler != NULL);
if (!SecurityHandler) {
return EFI_INVALID_PARAMETER;
}
// //
// Make sure AuthenticationOperation is valid in the register order. // Make sure AuthenticationOperation is valid in the register order.
// //
ASSERT (CheckAuthenticationOperation (mCurrentAuthOperation, AuthenticationOperation)); ASSERT (CheckAuthenticationOperation (mCurrentAuthOperation, AuthenticationOperation));
if (!CheckAuthenticationOperation (mCurrentAuthOperation, AuthenticationOperation)) {
return EFI_INVALID_PARAMETER;
}
mCurrentAuthOperation = mCurrentAuthOperation | AuthenticationOperation; mCurrentAuthOperation = mCurrentAuthOperation | AuthenticationOperation;
// //
@ -162,6 +168,9 @@ RegisterSecurityHandler (
// //
Status = ReallocateSecurityHandlerTable(); Status = ReallocateSecurityHandlerTable();
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (EFI_ERROR(Status)) {
return Status;
}
} }
// //
@ -399,11 +408,17 @@ RegisterSecurity2Handler (
EFI_STATUS Status; EFI_STATUS Status;
ASSERT (Security2Handler != NULL); ASSERT (Security2Handler != NULL);
if (!Security2Handler) {
return EFI_INVALID_PARAMETER;
}
// //
// Make sure AuthenticationOperation is valid in the register order. // Make sure AuthenticationOperation is valid in the register order.
// //
ASSERT (CheckAuthentication2Operation (mCurrentAuthOperation2, AuthenticationOperation)); ASSERT (CheckAuthentication2Operation (mCurrentAuthOperation2, AuthenticationOperation));
if (!CheckAuthentication2Operation (mCurrentAuthOperation2, AuthenticationOperation)) {
return EFI_INVALID_PARAMETER;
}
mCurrentAuthOperation2 = mCurrentAuthOperation2 | AuthenticationOperation; mCurrentAuthOperation2 = mCurrentAuthOperation2 | AuthenticationOperation;
// //
@ -415,6 +430,9 @@ RegisterSecurity2Handler (
// //
Status = ReallocateSecurity2HandlerTable(); Status = ReallocateSecurity2HandlerTable();
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (EFI_ERROR(Status)) {
return Status;
}
} }
// //

View File

@ -1286,6 +1286,9 @@ BmGetRamDiskMemoryInfo (
UINT64 EndingAddr; UINT64 EndingAddr;
ASSERT (RamDiskDevicePath != NULL); ASSERT (RamDiskDevicePath != NULL);
if (!RamDiskDevicePath) {
return NULL;
}
*RamDiskSizeInPages = 0; *RamDiskSizeInPages = 0;
@ -1294,6 +1297,9 @@ BmGetRamDiskMemoryInfo (
// //
Status = gBS->LocateDevicePath (&gEfiLoadFileProtocolGuid, &RamDiskDevicePath, &Handle); Status = gBS->LocateDevicePath (&gEfiLoadFileProtocolGuid, &RamDiskDevicePath, &Handle);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (EFI_ERROR(Status)) {
return NULL;
}
ASSERT ((DevicePathType (RamDiskDevicePath) == MEDIA_DEVICE_PATH) && ASSERT ((DevicePathType (RamDiskDevicePath) == MEDIA_DEVICE_PATH) &&
(DevicePathSubType (RamDiskDevicePath) == MEDIA_RAM_DISK_DP)); (DevicePathSubType (RamDiskDevicePath) == MEDIA_RAM_DISK_DP));
StartingAddr = ReadUnaligned64 ((UINT64 *) ((MEDIA_RAM_DISK_DEVICE_PATH *) RamDiskDevicePath)->StartingAddr); StartingAddr = ReadUnaligned64 ((UINT64 *) ((MEDIA_RAM_DISK_DEVICE_PATH *) RamDiskDevicePath)->StartingAddr);
@ -1321,6 +1327,10 @@ BmDestroyRamDisk (
UINTN RamDiskSizeInPages; UINTN RamDiskSizeInPages;
ASSERT (RamDiskDevicePath != NULL); ASSERT (RamDiskDevicePath != NULL);
if (!RamDiskDevicePath) {
return;
}
RamDiskBuffer = BmGetRamDiskMemoryInfo (RamDiskDevicePath, &RamDiskSizeInPages); RamDiskBuffer = BmGetRamDiskMemoryInfo (RamDiskDevicePath, &RamDiskSizeInPages);
@ -1330,9 +1340,12 @@ BmDestroyRamDisk (
if (mRamDisk == NULL) { if (mRamDisk == NULL) {
Status = gBS->LocateProtocol (&gEfiRamDiskProtocolGuid, NULL, (VOID *) &mRamDisk); Status = gBS->LocateProtocol (&gEfiRamDiskProtocolGuid, NULL, (VOID *) &mRamDisk);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (EFI_ERROR(Status)) {
return;
} }
Status = mRamDisk->Unregister (RamDiskDevicePath); }
ASSERT_EFI_ERROR (Status); /* Status = */mRamDisk->Unregister (RamDiskDevicePath);
// ASSERT_EFI_ERROR (Status);
FreePages (RamDiskBuffer, RamDiskSizeInPages); FreePages (RamDiskBuffer, RamDiskSizeInPages);
} }
@ -1366,6 +1379,10 @@ BmExpandLoadFile (
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (EFI_ERROR(Status)) {
return NULL;
}
FileBuffer = NULL; FileBuffer = NULL;
BufferSize = 0; BufferSize = 0;
@ -1534,6 +1551,9 @@ BmGetNextLoadOptionDevicePath (
EFI_STATUS Status; EFI_STATUS Status;
ASSERT (FilePath != NULL); ASSERT (FilePath != NULL);
if (!FilePath) {
return NULL;
}
// //
// Boot from media device by adding a default file name \EFI\BOOT\BOOT{machine type short-name}.EFI // Boot from media device by adding a default file name \EFI\BOOT\BOOT{machine type short-name}.EFI
@ -2292,6 +2312,7 @@ EfiBootManagerRefreshAllBootOption (
// Deleting variable with current variable implementation shouldn't fail. // Deleting variable with current variable implementation shouldn't fail.
// //
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (EFI_ERROR(Status)) break;
} }
} }
} }
@ -2404,6 +2425,9 @@ BmRegisterBootManagerMenu (
(VOID **) &LoadedImage (VOID **) &LoadedImage
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
return Status;
}
DevicePath = AppendDevicePathNode ( DevicePath = AppendDevicePathNode (
DevicePathFromHandle (LoadedImage->DeviceHandle), DevicePathFromHandle (LoadedImage->DeviceHandle),
(EFI_DEVICE_PATH_PROTOCOL *) &FileNode (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
@ -2422,11 +2446,16 @@ BmRegisterBootManagerMenu (
0 0
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
return Status;
}
if (DevicePath) {
FreePool (DevicePath); FreePool (DevicePath);
}
if (Description != NULL) { if (Description != NULL) {
FreePool (Description); FreePool (Description);
} }
/*
DEBUG_CODE ( DEBUG_CODE (
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
UINTN BootOptionCount; UINTN BootOptionCount;
@ -2435,7 +2464,7 @@ BmRegisterBootManagerMenu (
ASSERT (EfiBootManagerFindLoadOption (BootOption, BootOptions, BootOptionCount) == -1); ASSERT (EfiBootManagerFindLoadOption (BootOption, BootOptions, BootOptionCount) == -1);
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount); EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
); );
*/
return EfiBootManagerAddLoadOptionVariable (BootOption, 0); return EfiBootManagerAddLoadOptionVariable (BootOption, 0);
} }
@ -2457,7 +2486,7 @@ EfiBootManagerGetBootManagerMenu (
EFI_BOOT_MANAGER_LOAD_OPTION *BootOption EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
) )
{ {
EFI_STATUS Status; // EFI_STATUS Status;
UINTN BootOptionCount; UINTN BootOptionCount;
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
UINTN Index; UINTN Index;
@ -2466,7 +2495,7 @@ EfiBootManagerGetBootManagerMenu (
for (Index = 0; Index < BootOptionCount; Index++) { for (Index = 0; Index < BootOptionCount; Index++) {
if (BmIsBootManagerMenuFilePath (BootOptions[Index].FilePath)) { if (BmIsBootManagerMenuFilePath (BootOptions[Index].FilePath)) {
Status = EfiBootManagerInitializeLoadOption ( /*Status = */EfiBootManagerInitializeLoadOption (
BootOption, BootOption,
BootOptions[Index].OptionNumber, BootOptions[Index].OptionNumber,
BootOptions[Index].OptionType, BootOptions[Index].OptionType,
@ -2476,7 +2505,8 @@ EfiBootManagerGetBootManagerMenu (
BootOptions[Index].OptionalData, BootOptions[Index].OptionalData,
BootOptions[Index].OptionalDataSize BootOptions[Index].OptionalDataSize
); );
ASSERT_EFI_ERROR (Status); // ASSERT_EFI_ERROR (Status);
break; break;
} }
} }

View File

@ -683,6 +683,7 @@ BmProcessKeyOption (
for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) { for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
Status = gBS->HandleProtocol (Handles[HandleIndex], &gEfiSimpleTextInputExProtocolGuid, (VOID **) &TxtInEx); Status = gBS->HandleProtocol (Handles[HandleIndex], &gEfiSimpleTextInputExProtocolGuid, (VOID **) &TxtInEx);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (EFI_ERROR(Status)) continue;
BmRegisterHotkeyNotify (TxtInEx, Hotkey); BmRegisterHotkeyNotify (TxtInEx, Hotkey);
} }
} }

View File

@ -152,6 +152,9 @@ HiiAddPackages (
UINT8 *Data; UINT8 *Data;
ASSERT (PackageListGuid != NULL); ASSERT (PackageListGuid != NULL);
if (!PackageListGuid) {
return NULL;
}
// //
// Calculate the length of all the packages in the variable argument list // Calculate the length of all the packages in the variable argument list
@ -251,11 +254,14 @@ HiiRemovePackages (
IN EFI_HII_HANDLE HiiHandle IN EFI_HII_HANDLE HiiHandle
) )
{ {
EFI_STATUS Status; // EFI_STATUS Status;
ASSERT (HiiHandle != NULL); ASSERT (HiiHandle != NULL);
Status = gHiiDatabase->RemovePackageList (gHiiDatabase, HiiHandle); if (!HiiHandle) {
ASSERT_EFI_ERROR (Status); return;
}
/* Status = */gHiiDatabase->RemovePackageList (gHiiDatabase, HiiHandle);
// ASSERT_EFI_ERROR (Status);
} }

View File

@ -230,6 +230,16 @@ DevicePathCompare (
(VOID**)&mUnicodeCollation); (VOID**)&mUnicodeCollation);
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR(Status);
if (EFI_ERROR(Status)) {
return -1;
}
/* if (EFI_ERROR(Status)) {
Status = gBS->LocateProtocol(
&gEfiUnicodeCollationProtocolGuid,
NULL,
(VOID**)&mUnicodeCollation);
} */
} }
TextPath1 = ConvertDevicePathToText( TextPath1 = ConvertDevicePathToText(
@ -247,10 +257,14 @@ DevicePathCompare (
} else if (TextPath2 == NULL) { } else if (TextPath2 == NULL) {
RetVal = 1; RetVal = 1;
} else { } else {
if (mUnicodeCollation) {
RetVal = mUnicodeCollation->StriColl( RetVal = mUnicodeCollation->StriColl(
mUnicodeCollation, mUnicodeCollation,
TextPath1, TextPath1,
TextPath2); TextPath2);
} else {
RetVal = 1;
}
} }
USL_FREE_NON_NULL(TextPath1); USL_FREE_NON_NULL(TextPath1);
@ -284,6 +298,9 @@ StringNoCaseCompare (
(VOID**)&mUnicodeCollation); (VOID**)&mUnicodeCollation);
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR(Status);
if (EFI_ERROR(Status)) {
return -1;
}
} }
return (mUnicodeCollation->StriColl( return (mUnicodeCollation->StriColl(

View File

@ -43,13 +43,16 @@ StrCpy (
) )
{ {
CHAR16 *ReturnValue; CHAR16 *ReturnValue;
INTN DestMax; // INTN DestMax;
// //
// Destination cannot be NULL // Destination cannot be NULL
// //
ASSERT (Destination != NULL); ASSERT (Destination != NULL);
ASSERT (((UINTN) Destination & BIT0) == 0); ASSERT (((UINTN) Destination & BIT0) == 0);
if (!Destination || !Source) {
return NULL;
}
// //
// Destination and source cannot overlap // Destination and source cannot overlap
@ -57,7 +60,7 @@ StrCpy (
ASSERT ((UINTN)(Destination - Source) > StrLen (Source)); ASSERT ((UINTN)(Destination - Source) > StrLen (Source));
ASSERT ((UINTN)(Source - Destination) > StrLen (Source)); ASSERT ((UINTN)(Source - Destination) > StrLen (Source));
DestMax = StrLen (Destination); // DestMax = StrLen (Destination);
ReturnValue = Destination; ReturnValue = Destination;
while (*Source != 0) { while (*Source != 0) {

View File

@ -154,7 +154,8 @@ AcquireSpinLock (
Delta += Cycle; Delta += Cycle;
} }
Total += Delta; Total += Delta;
ASSERT (Total < Timeout); // ASSERT (Total < Timeout);
if (Total >= Timeout) break;
} }
} }
return SpinLock; return SpinLock;
@ -187,9 +188,15 @@ AcquireSpinLockOrFail (
VOID *Result; VOID *Result;
ASSERT (SpinLock != NULL); ASSERT (SpinLock != NULL);
if (!SpinLock) {
return FALSE;
}
LockValue = *SpinLock; LockValue = *SpinLock;
ASSERT (LockValue == SPIN_LOCK_ACQUIRED || LockValue == SPIN_LOCK_RELEASED); ASSERT (LockValue == SPIN_LOCK_ACQUIRED || LockValue == SPIN_LOCK_RELEASED);
if (!(LockValue == SPIN_LOCK_ACQUIRED || LockValue == SPIN_LOCK_RELEASED)) {
return FALSE;
}
_ReadWriteBarrier (); _ReadWriteBarrier ();
Result = InterlockedCompareExchangePointer ( Result = InterlockedCompareExchangePointer (
@ -225,9 +232,15 @@ ReleaseSpinLock (
SPIN_LOCK LockValue; SPIN_LOCK LockValue;
ASSERT (SpinLock != NULL); ASSERT (SpinLock != NULL);
if (!SpinLock) {
return NULL;
}
LockValue = *SpinLock; LockValue = *SpinLock;
ASSERT (LockValue == SPIN_LOCK_ACQUIRED || LockValue == SPIN_LOCK_RELEASED); ASSERT (LockValue == SPIN_LOCK_ACQUIRED || LockValue == SPIN_LOCK_RELEASED);
if (!(LockValue == SPIN_LOCK_ACQUIRED || LockValue == SPIN_LOCK_RELEASED)) {
return NULL;
}
_ReadWriteBarrier (); _ReadWriteBarrier ();
*SpinLock = SPIN_LOCK_RELEASED; *SpinLock = SPIN_LOCK_RELEASED;

View File

@ -46,6 +46,9 @@ GetHobList (
if (mHobList == NULL) { if (mHobList == NULL) {
Status = EfiGetSystemConfigurationTable (&gEfiHobListGuid, &mHobList); Status = EfiGetSystemConfigurationTable (&gEfiHobListGuid, &mHobList);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (EFI_ERROR(Status)) {
return NULL;
}
ASSERT (mHobList != NULL); ASSERT (mHobList != NULL);
} }
return mHobList; return mHobList;

View File

@ -45,6 +45,9 @@ GetPiPcdProtocol (
// //
Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID **) &mPiPcd); Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID **) &mPiPcd);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (EFI_ERROR(Status)) {
return NULL;
}
ASSERT (mPiPcd != NULL); ASSERT (mPiPcd != NULL);
} }
return mPiPcd; return mPiPcd;
@ -70,6 +73,9 @@ GetPcdProtocol (
// //
Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **)&mPcd); Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **)&mPcd);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (EFI_ERROR(Status)) {
return NULL;
}
ASSERT (mPcd != NULL); ASSERT (mPcd != NULL);
} }
return mPcd; return mPcd;
@ -90,6 +96,9 @@ GetPiPcdInfoProtocolPointer (
if (mPiPcdInfo == NULL) { if (mPiPcdInfo == NULL) {
Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, (VOID **)&mPiPcdInfo); Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, (VOID **)&mPiPcdInfo);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (EFI_ERROR(Status)) {
return NULL;
}
ASSERT (mPiPcdInfo != NULL); ASSERT (mPiPcdInfo != NULL);
} }
return mPiPcdInfo; return mPiPcdInfo;
@ -110,6 +119,9 @@ GetPcdInfoProtocolPointer (
if (mPcdInfo == NULL) { if (mPcdInfo == NULL) {
Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID **)&mPcdInfo); Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID **)&mPcdInfo);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (EFI_ERROR(Status)) {
return NULL;
}
ASSERT (mPcdInfo != NULL); ASSERT (mPcdInfo != NULL);
} }
return mPcdInfo; return mPcdInfo;
@ -1134,6 +1146,9 @@ LibPcdSetEx64S (
) )
{ {
ASSERT (Guid != NULL); ASSERT (Guid != NULL);
if (!Guid) {
return EFI_INVALID_PARAMETER;
}
return GetPiPcdProtocol()->Set64 (Guid, TokenNumber, Value); return GetPiPcdProtocol()->Set64 (Guid, TokenNumber, Value);
} }
@ -1172,6 +1187,9 @@ LibPcdSetExPtrS (
ASSERT (Guid != NULL); ASSERT (Guid != NULL);
ASSERT (SizeOfBuffer != NULL); ASSERT (SizeOfBuffer != NULL);
if (!Guid || !SizeOfBuffer) {
return EFI_INVALID_PARAMETER;
}
if (*SizeOfBuffer > 0) { if (*SizeOfBuffer > 0) {
ASSERT (Buffer != NULL); ASSERT (Buffer != NULL);
@ -1205,6 +1223,9 @@ LibPcdSetExBoolS (
) )
{ {
ASSERT (Guid != NULL); ASSERT (Guid != NULL);
if (!Guid) {
return EFI_INVALID_PARAMETER;
}
return GetPiPcdProtocol()->SetBool (Guid, TokenNumber, Value); return GetPiPcdProtocol()->SetBool (Guid, TokenNumber, Value);
} }
@ -1233,12 +1254,12 @@ LibPcdCallbackOnSet (
IN PCD_CALLBACK NotificationFunction IN PCD_CALLBACK NotificationFunction
) )
{ {
EFI_STATUS Status; // EFI_STATUS Status;
ASSERT (NotificationFunction != NULL); ASSERT (NotificationFunction != NULL);
Status = GetPiPcdProtocol()->CallbackOnSet (Guid, TokenNumber, (EFI_PCD_PROTOCOL_CALLBACK) NotificationFunction); /* Status = */GetPiPcdProtocol()->CallbackOnSet (Guid, TokenNumber, (EFI_PCD_PROTOCOL_CALLBACK) NotificationFunction);
ASSERT_EFI_ERROR (Status); // ASSERT_EFI_ERROR (Status);
return; return;
} }
@ -1266,12 +1287,12 @@ LibPcdCancelCallback (
IN PCD_CALLBACK NotificationFunction IN PCD_CALLBACK NotificationFunction
) )
{ {
EFI_STATUS Status; // EFI_STATUS Status;
ASSERT (NotificationFunction != NULL); ASSERT (NotificationFunction != NULL);
Status = GetPiPcdProtocol()->CancelCallback (Guid, TokenNumber, (EFI_PCD_PROTOCOL_CALLBACK) NotificationFunction); /* Status = */GetPiPcdProtocol()->CancelCallback (Guid, TokenNumber, (EFI_PCD_PROTOCOL_CALLBACK) NotificationFunction);
ASSERT_EFI_ERROR (Status); // ASSERT_EFI_ERROR (Status);
return; return;
} }
@ -1308,6 +1329,9 @@ LibPcdGetNextToken (
Status = GetPiPcdProtocol()->GetNextToken (Guid, &TokenNumber); Status = GetPiPcdProtocol()->GetNextToken (Guid, &TokenNumber);
ASSERT (!EFI_ERROR (Status) || TokenNumber == 0); ASSERT (!EFI_ERROR (Status) || TokenNumber == 0);
if (EFI_ERROR (Status)) {
TokenNumber = 0;
}
return TokenNumber; return TokenNumber;
} }

View File

@ -808,6 +808,9 @@ DriverEfiVersionProtocolDumpInformation(
(VOID**)&DriverEfiVersion); (VOID**)&DriverEfiVersion);
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR(Status);
if (EFI_ERROR(Status)) {
return NULL;
}
RetVal = AllocateZeroPool(VersionStringSize); RetVal = AllocateZeroPool(VersionStringSize);
if (RetVal != NULL) { if (RetVal != NULL) {

View File

@ -1399,8 +1399,10 @@ ShellCommandCreateInitialMappingsAndPaths(
// //
NewDefaultName = ShellCommandCreateNewMappingName(MappingTypeFileSystem); NewDefaultName = ShellCommandCreateNewMappingName(MappingTypeFileSystem);
ASSERT(NewDefaultName != NULL); ASSERT(NewDefaultName != NULL);
if (!NewDefaultName) break;
Status = ShellCommandAddMapItemAndUpdatePath(NewDefaultName, DevicePathList[Count], 0, TRUE); Status = ShellCommandAddMapItemAndUpdatePath(NewDefaultName, DevicePathList[Count], 0, TRUE);
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR(Status);
if (EFI_ERROR(Status)) break;
FreePool(NewDefaultName); FreePool(NewDefaultName);
// //
@ -1411,6 +1413,7 @@ ShellCommandCreateInitialMappingsAndPaths(
Status = ShellCommandAddMapItemAndUpdatePath(NewConsistName, DevicePathList[Count], 0, FALSE); Status = ShellCommandAddMapItemAndUpdatePath(NewConsistName, DevicePathList[Count], 0, FALSE);
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR(Status);
FreePool(NewConsistName); FreePool(NewConsistName);
if (EFI_ERROR(Status)) break;
} }
} }

View File

@ -73,6 +73,9 @@ ShellCommandRunEndFor (
Status = CommandInit(); Status = CommandInit();
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR(Status);
if (EFI_ERROR(Status)) {
return Status;
}
if (!gEfiShellProtocol->BatchIsActive()) { if (!gEfiShellProtocol->BatchIsActive()) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"endfor"); ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"endfor");

View File

@ -1002,6 +1002,9 @@ ShellCommandRunElse (
Status = CommandInit (); Status = CommandInit ();
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (EFI_ERROR(Status)) {
return Status;
}
if (gEfiShellParametersProtocol->Argc > 1) { if (gEfiShellParametersProtocol->Argc > 1) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"if"); ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"if");
@ -1080,6 +1083,10 @@ ShellCommandRunEndIf (
Status = CommandInit (); Status = CommandInit ();
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (EFI_ERROR(Status)) {
return Status;
}
if (gEfiShellParametersProtocol->Argc > 1) { if (gEfiShellParametersProtocol->Argc > 1) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"if"); ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"if");

View File

@ -34,6 +34,9 @@ ShellCommandRunShift (
Status = CommandInit(); Status = CommandInit();
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR(Status);
if (EFI_ERROR(Status)) {
return Status;
}
if (!gEfiShellProtocol->BatchIsActive()) { if (!gEfiShellProtocol->BatchIsActive()) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"shift"); ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"shift");
@ -42,6 +45,9 @@ ShellCommandRunShift (
CurrentScriptFile = ShellCommandGetCurrentScriptFile(); CurrentScriptFile = ShellCommandGetCurrentScriptFile();
ASSERT(CurrentScriptFile != NULL); ASSERT(CurrentScriptFile != NULL);
if (!CurrentScriptFile) {
return (SHELL_UNSUPPORTED);
}
if (CurrentScriptFile->Argc < 2) { if (CurrentScriptFile->Argc < 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"shift"); ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"shift");

View File

@ -380,7 +380,7 @@ EFIAPI
ShellInitialize ( ShellInitialize (
) )
{ {
EFI_STATUS Status; // EFI_STATUS Status;
// //
// if auto initialize is not false then skip // if auto initialize is not false then skip
@ -392,8 +392,8 @@ ShellInitialize (
// //
// deinit the current stuff // deinit the current stuff
// //
Status = ShellLibDestructor (gImageHandle, gST); /* Status = */ShellLibDestructor (gImageHandle, gST);
ASSERT_EFI_ERROR (Status); // ASSERT_EFI_ERROR (Status);
// //
// init the new stuff // init the new stuff