summaryrefslogtreecommitdiffstats
path: root/ShellPkg
diff options
context:
space:
mode:
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2010-11-12 21:40:12 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2010-11-12 21:40:12 +0000
commitff51746bd46b25a88eb6c131c52e1d9fd610af28 (patch)
tree81daad0e45e04e9171714e22b59e356e0c426e2e /ShellPkg
parenta12e31e6801ba07da25425bb546a65a61a78b1c2 (diff)
downloadedk2-ff51746bd46b25a88eb6c131c52e1d9fd610af28.tar.gz
edk2-ff51746bd46b25a88eb6c131c52e1d9fd610af28.tar.bz2
edk2-ff51746bd46b25a88eb6c131c52e1d9fd610af28.zip
update error handling to use less ASSERT.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11053 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Include/Library/HandleParsingLib.h3
-rw-r--r--ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c21
-rw-r--r--ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c18
3 files changed, 29 insertions, 13 deletions
diff --git a/ShellPkg/Include/Library/HandleParsingLib.h b/ShellPkg/Include/Library/HandleParsingLib.h
index b8166ff76f..8c0b81d12c 100644
--- a/ShellPkg/Include/Library/HandleParsingLib.h
+++ b/ShellPkg/Include/Library/HandleParsingLib.h
@@ -331,7 +331,8 @@ GetHandleListByProtocol (
@param[in] ProtocolGuids A NULL terminated list of protocol GUIDs.
@retval NULL A memory allocation failed.
- @return A NULL terminated list of handles.
+ @retval NULL ProtocolGuids was NULL.
+ @return A NULL terminated list of EFI_HANDLEs.
**/
EFI_HANDLE*
EFIAPI
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index 107b3354e5..6b59bfd6ab 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -1105,7 +1105,9 @@ ParseHandleDatabaseForChildControllers(
BOOLEAN Found;
EFI_HANDLE *HandleBufferForReturn;
- ASSERT (MatchingHandleCount != NULL);
+ if (MatchingHandleCount == NULL) {
+ return (EFI_INVALID_PARAMETER);
+ }
Status = PARSE_HANDLE_DATABASE_UEFI_DRIVERS (
ControllerHandle,
@@ -1116,10 +1118,13 @@ ParseHandleDatabaseForChildControllers(
return Status;
}
- HandleBufferForReturn = GetHandleListByProtocol(&gEfiDriverBindingProtocolGuid);
+ //
+ // Get a buffer big enough for all the controllers.
+ //
+ HandleBufferForReturn = GetHandleListByProtocol(&gEfiDevicePathProtocolGuid);
if (HandleBufferForReturn == NULL) {
FreePool (DriverBindingHandleBuffer);
- return Status;
+ return (EFI_NOT_FOUND);
}
*MatchingHandleCount = 0;
@@ -1361,7 +1366,8 @@ GetHandleListByProtocol (
@param[in] ProtocolGuids A NULL terminated list of protocol GUIDs.
@retval NULL A memory allocation failed.
- @return A NULL terminated list of handles.
+ @retval NULL ProtocolGuids was NULL.
+ @return A NULL terminated list of EFI_HANDLEs.
**/
EFI_HANDLE*
EFIAPI
@@ -1397,7 +1403,6 @@ GetHandleListByProtocolList (
}
HandleList = AllocateZeroPool(TotalSize);
- ASSERT(HandleList != NULL);
if (HandleList == NULL) {
return (NULL);
}
@@ -1405,16 +1410,16 @@ GetHandleListByProtocolList (
Size = 0;
for (GuidWalker = ProtocolGuids ; GuidWalker != NULL && *GuidWalker != NULL ; GuidWalker++){
TempSize = TotalSize - Size;
- Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)(*GuidWalker), NULL, &TempSize, HandleList+((TotalSize - Size)/sizeof(EFI_HANDLE)));
+ Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)(*GuidWalker), NULL, &TempSize, HandleList+(Size/sizeof(EFI_HANDLE)));
//
// Allow for missing protocols... Only update the 'used' size upon success.
//
if (!EFI_ERROR(Status)) {
- Size = TempSize;
+ Size += TempSize;
}
}
- HandleList[(TotalSize/sizeof(EFI_HANDLE))-1] = NULL;
+ ASSERT(HandleList[(TotalSize/sizeof(EFI_HANDLE))-1] == NULL);
for (HandleWalker1 = HandleList ; HandleWalker1 != NULL && *HandleWalker1 != NULL ; HandleWalker1++) {
for (HandleWalker2 = HandleWalker1 + 1; HandleWalker2 != NULL && *HandleWalker2 != NULL ; HandleWalker2++) {
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
index 4aec5d44ca..2dd39ef3cf 100644
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
+++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
@@ -1171,7 +1171,8 @@ ConvertShellHandleToEfiFileProtocol(
@param[in] Handle The pointer to EFI_FILE_PROTOCOL to convert.
@param[in] Path The path to the file for verification.
- @return a SHELL_FILE_HANDLE representing the same file.
+ @return A SHELL_FILE_HANDLE representing the same file.
+ @retval NULL There was not enough memory.
**/
SHELL_FILE_HANDLE
EFIAPI
@@ -1185,11 +1186,18 @@ ConvertEfiFileProtocolToShellHandle(
if (Path != NULL) {
Buffer = AllocateZeroPool(sizeof(SHELL_COMMAND_FILE_HANDLE));
- ASSERT(Buffer != NULL);
+ if (Buffer == NULL) {
+ return (NULL);
+ }
NewNode = AllocatePool(sizeof(BUFFER_LIST));
- ASSERT(NewNode != NULL);
+ if (NewNode == NULL) {
+ return (NULL);
+ }
Buffer->FileHandle = (EFI_FILE_PROTOCOL*)Handle;
Buffer->Path = StrnCatGrow(&Buffer->Path, NULL, Path, 0);
+ if (Buffer->Path == NULL) {
+ return (NULL);
+ }
NewNode->Buffer = Buffer;
InsertHeadList(&mFileHandleList.Link, &NewNode->Link);
@@ -1244,8 +1252,10 @@ ShellFileHandleRemove(
; Node = (BUFFER_LIST*)GetNextNode(&mFileHandleList.Link, &Node->Link)
){
if ((Node->Buffer) && (((SHELL_COMMAND_FILE_HANDLE *)Node->Buffer)->FileHandle == Handle)){
- SHELL_FREE_NON_NULL(((SHELL_COMMAND_FILE_HANDLE *)Node->Buffer)->Path);
RemoveEntryList(&Node->Link);
+ SHELL_FREE_NON_NULL(((SHELL_COMMAND_FILE_HANDLE *)Node->Buffer)->Path);
+ SHELL_FREE_NON_NULL(Node->Buffer);
+ SHELL_FREE_NON_NULL(Node);
return (TRUE);
}
}