replace protocol presence ASSERTs with error returns.

signed-off-by: jcarsey
reviewed-by: lgrosenb

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11899 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jcarsey 2011-06-27 20:33:13 +00:00
parent ad7782a47e
commit 92a5447eda
1 changed files with 86 additions and 76 deletions

View File

@ -483,12 +483,10 @@ ShellOpenFileByDevicePath(
EFI_FILE_PROTOCOL *Handle1; EFI_FILE_PROTOCOL *Handle1;
EFI_FILE_PROTOCOL *Handle2; EFI_FILE_PROTOCOL *Handle2;
// if (FilePath == NULL || FileHandle == NULL || DeviceHandle == NULL) {
// ASERT for FileHandle, FilePath, and DeviceHandle being NULL return (EFI_INVALID_PARAMETER);
// }
ASSERT(FilePath != NULL);
ASSERT(FileHandle != NULL);
ASSERT(DeviceHandle != NULL);
// //
// which shell interface should we use // which shell interface should we use
// //
@ -601,7 +599,7 @@ ShellOpenFileByDevicePath(
otherwise, the Filehandle is NULL. The Attributes is valid only for otherwise, the Filehandle is NULL. The Attributes is valid only for
EFI_FILE_MODE_CREATE. EFI_FILE_MODE_CREATE.
if FileNAme is NULL then ASSERT() if FileName is NULL then ASSERT()
@param FileName pointer to file name @param FileName pointer to file name
@param FileHandle pointer to the file handle. @param FileHandle pointer to the file handle.
@ -1047,8 +1045,11 @@ ShellGetExecutionBreakFlag(
// //
// using EFI Shell; call the function to check // using EFI Shell; call the function to check
// //
ASSERT(mEfiShellEnvironment2 != NULL); if (mEfiShellEnvironment2 != NULL) {
return (mEfiShellEnvironment2->GetExecutionBreak()); return (mEfiShellEnvironment2->GetExecutionBreak());
}
return (FALSE);
} }
/** /**
return the value of an environment variable return the value of an environment variable
@ -1075,14 +1076,13 @@ ShellGetEnvironmentVariable (
} }
// //
// ASSERT that we must have EFI shell // Check for EFI shell
//
ASSERT(mEfiShellEnvironment2 != NULL);
//
// using EFI Shell
// //
if (mEfiShellEnvironment2 != NULL) {
return (mEfiShellEnvironment2->GetEnv((CHAR16*)EnvKey)); return (mEfiShellEnvironment2->GetEnv((CHAR16*)EnvKey));
}
return NULL;
} }
/** /**
set the value of an environment variable set the value of an environment variable
@ -1177,10 +1177,11 @@ ShellExecute (
EnvironmentVariables, EnvironmentVariables,
Status)); Status));
} }
// //
// ASSERT that we must have EFI shell // Check for EFI shell
// //
ASSERT(mEfiShellEnvironment2 != NULL); if (mEfiShellEnvironment2 != NULL) {
// //
// Call EFI Shell version (not using EnvironmentVariables or Status parameters) // Call EFI Shell version (not using EnvironmentVariables or Status parameters)
// Due to oddity in the EFI shell we want to dereference the ParentHandle here // Due to oddity in the EFI shell we want to dereference the ParentHandle here
@ -1188,6 +1189,9 @@ ShellExecute (
return (mEfiShellEnvironment2->Execute(*ParentHandle, return (mEfiShellEnvironment2->Execute(*ParentHandle,
CommandLine, CommandLine,
Output)); Output));
}
return (EFI_UNSUPPORTED);
} }
/** /**
Retreives the current directory path Retreives the current directory path
@ -1213,6 +1217,7 @@ ShellGetCurrentDir (
if (mEfiShellProtocol != NULL) { if (mEfiShellProtocol != NULL) {
return (mEfiShellProtocol->GetCurDir(DeviceName)); return (mEfiShellProtocol->GetCurDir(DeviceName));
} }
// //
// Check for EFI shell // Check for EFI shell
// //
@ -1251,15 +1256,16 @@ ShellSetPageBreakMode (
return; return;
} else { } else {
// //
// ASSERT that must have EFI Shell // Check for EFI shell
// //
ASSERT(mEfiShellEnvironment2 != NULL); if (mEfiShellEnvironment2 != NULL) {
// //
// Enable with EFI Shell // Enable with EFI Shell
// //
mEfiShellEnvironment2->EnablePageBreak (DEFAULT_INIT_ROW, DEFAULT_AUTO_LF); mEfiShellEnvironment2->EnablePageBreak (DEFAULT_INIT_ROW, DEFAULT_AUTO_LF);
return; return;
} }
}
} else { } else {
// //
// check for UEFI Shell 2.0 // check for UEFI Shell 2.0
@ -1272,9 +1278,9 @@ ShellSetPageBreakMode (
return; return;
} else { } else {
// //
// ASSERT that must have EFI Shell // Check for EFI shell
// //
ASSERT(mEfiShellEnvironment2 != NULL); if (mEfiShellEnvironment2 != NULL) {
// //
// Disable with EFI Shell // Disable with EFI Shell
// //
@ -1282,6 +1288,7 @@ ShellSetPageBreakMode (
return; return;
} }
} }
}
} }
/// ///
@ -1463,10 +1470,9 @@ ShellOpenFileMetaArg (
} }
// //
// ASSERT that we must have EFI shell // Check for EFI shell
// //
ASSERT(mEfiShellEnvironment2 != NULL); if (mEfiShellEnvironment2 != NULL) {
// //
// make sure the list head is initialized // make sure the list head is initialized
// //
@ -1504,8 +1510,10 @@ ShellOpenFileMetaArg (
*ListHead = NULL; *ListHead = NULL;
Status = EFI_NOT_FOUND; Status = EFI_NOT_FOUND;
} }
return (Status); return (Status);
}
return (EFI_UNSUPPORTED);
} }
/** /**
Free the linked list returned from ShellOpenFileMetaArg. Free the linked list returned from ShellOpenFileMetaArg.
@ -1534,7 +1542,7 @@ ShellCloseFileMetaArg (
// //
if (mEfiShellProtocol != NULL) { if (mEfiShellProtocol != NULL) {
return (mEfiShellProtocol->FreeFileList(ListHead)); return (mEfiShellProtocol->FreeFileList(ListHead));
} else { } else if (mEfiShellEnvironment2 != NULL) {
// //
// Since this is EFI Shell version we need to free our internally made copy // Since this is EFI Shell version we need to free our internally made copy
// of the list // of the list
@ -1551,6 +1559,8 @@ ShellCloseFileMetaArg (
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
return (EFI_UNSUPPORTED);
} }
/** /**