summaryrefslogtreecommitdiff
path: root/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
diff options
context:
space:
mode:
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2011-04-01 22:16:01 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2011-04-01 22:16:01 +0000
commitae724571beb0cff6edefe42942b7cdc7aa81ee94 (patch)
treeaebe447e031e49a703e77503dec70dcaf46bed30 /ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
parent5f2915f59380777728344bbbca587d4944f19ed0 (diff)
downloadedk2-platforms-ae724571beb0cff6edefe42942b7cdc7aa81ee94.tar.xz
Comment's added and fixed.
Pointer's checked for NULL before access and after memory allocations. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11499 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library/UefiShellLevel1CommandsLib/If.c')
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/If.c60
1 files changed, 38 insertions, 22 deletions
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
index a3c4482bb3..1d83f8a246 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
@@ -825,7 +825,7 @@ ShellCommandRunIf (
BOOLEAN CurrentValue;
END_TAG_TYPE Ending;
END_TAG_TYPE PreviousEnding;
-
+ SCRIPT_FILE *CurrentScriptFile;
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
@@ -843,7 +843,8 @@ ShellCommandRunIf (
//
// Make sure that an End exists.
//
- if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, ShellCommandGetCurrentScriptFile(), TRUE, TRUE, FALSE)) {
+ CurrentScriptFile = ShellCommandGetCurrentScriptFile();
+ if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, CurrentScriptFile, TRUE, TRUE, FALSE)) {
ShellPrintHiiEx(
-1,
-1,
@@ -852,9 +853,9 @@ ShellCommandRunIf (
gShellLevel1HiiHandle,
L"EnfIf",
L"If",
- ShellCommandGetCurrentScriptFile()!=NULL
- &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
- ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR);
}
@@ -928,7 +929,18 @@ ShellCommandRunIf (
// build up the next statement for analysis
//
if (!BuildNextStatement(CurrentParameter, &EndParameter, &Ending)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"Then", L"If", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ CurrentScriptFile = ShellCommandGetCurrentScriptFile();
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
+ gShellLevel1HiiHandle,
+ L"Then",
+ L"If",
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
@@ -979,6 +991,7 @@ ShellCommandRunElse (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
+ SCRIPT_FILE *CurrentScriptFile;
ASSERT_EFI_ERROR(CommandInit());
if (gEfiShellParametersProtocol->Argc > 1) {
@@ -991,8 +1004,9 @@ ShellCommandRunElse (
return (SHELL_UNSUPPORTED);
}
+ CurrentScriptFile = ShellCommandGetCurrentScriptFile();
- if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) {
+ if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) {
ShellPrintHiiEx(
-1,
-1,
@@ -1001,12 +1015,12 @@ ShellCommandRunElse (
gShellLevel1HiiHandle,
L"If",
L"Else",
- ShellCommandGetCurrentScriptFile()!=NULL
- &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
- ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR);
}
- if (!MoveToTag(GetPreviousNode, L"if", L"else", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) {
+ if (!MoveToTag(GetPreviousNode, L"if", L"else", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) {
ShellPrintHiiEx(
-1,
-1,
@@ -1015,13 +1029,13 @@ ShellCommandRunElse (
gShellLevel1HiiHandle,
L"If",
L"Else",
- ShellCommandGetCurrentScriptFile()!=NULL
- &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
- ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR);
}
- if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, FALSE)) {
+ if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, CurrentScriptFile, FALSE, FALSE, FALSE)) {
ShellPrintHiiEx(
-1,
-1,
@@ -1030,9 +1044,9 @@ ShellCommandRunElse (
gShellLevel1HiiHandle,
L"EndIf",
"Else",
- ShellCommandGetCurrentScriptFile()!=NULL
- &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
- ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR);
}
@@ -1052,6 +1066,7 @@ ShellCommandRunEndIf (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
+ SCRIPT_FILE *CurrentScriptFile;
ASSERT_EFI_ERROR(CommandInit());
if (gEfiShellParametersProtocol->Argc > 1) {
@@ -1064,7 +1079,8 @@ ShellCommandRunEndIf (
return (SHELL_UNSUPPORTED);
}
- if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) {
+ CurrentScriptFile = ShellCommandGetCurrentScriptFile();
+ if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) {
ShellPrintHiiEx(
-1,
-1,
@@ -1073,9 +1089,9 @@ ShellCommandRunEndIf (
gShellLevel1HiiHandle,
L"If",
L"EndIf",
- ShellCommandGetCurrentScriptFile()!=NULL
- &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
- ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR);
}