diff options
author | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-04-01 22:16:01 +0000 |
---|---|---|
committer | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-04-01 22:16:01 +0000 |
commit | ae724571beb0cff6edefe42942b7cdc7aa81ee94 (patch) | |
tree | aebe447e031e49a703e77503dec70dcaf46bed30 /ShellPkg/Library/UefiShellLevel1CommandsLib | |
parent | 5f2915f59380777728344bbbca587d4944f19ed0 (diff) | |
download | edk2-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')
-rw-r--r-- | ShellPkg/Library/UefiShellLevel1CommandsLib/For.c | 108 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c | 8 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellLevel1CommandsLib/If.c | 60 |
3 files changed, 139 insertions, 37 deletions
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c index ddcfd45de3..64110099d3 100644 --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c +++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c @@ -69,6 +69,7 @@ ShellCommandRunEndFor ( {
EFI_STATUS Status;
BOOLEAN Found;
+ SCRIPT_FILE *CurrentScriptFile;
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
@@ -86,6 +87,7 @@ ShellCommandRunEndFor ( Found = MoveToTag(GetPreviousNode, L"for", L"endfor", NULL, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, FALSE);
if (!Found) {
+ CurrentScriptFile = ShellCommandGetCurrentScriptFile();
ShellPrintHiiEx(
-1,
-1,
@@ -94,9 +96,9 @@ ShellCommandRunEndFor ( gShellLevel1HiiHandle,
L"For",
L"EndFor",
- ShellCommandGetCurrentScriptFile()!=NULL
- &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
- ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
return (SHELL_NOT_FOUND);
}
return (SHELL_SUCCESS);
@@ -421,7 +423,16 @@ ShellCommandRunFor ( Info->CurrentValue = NULL;
ArgSetWalker = ArgSet;
if (ArgSetWalker[0] != L'(') {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
+ gShellLevel1HiiHandle,
+ ArgSet,
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
TempSpot = StrStr(ArgSetWalker, L")");
@@ -437,7 +448,15 @@ ShellCommandRunFor ( }
}
if (TempSpot == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
+ gShellLevel1HiiHandle,
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
*TempSpot = CHAR_NULL;
@@ -446,7 +465,16 @@ ShellCommandRunFor ( ArgSetWalker++;
}
if (!ShellIsValidForNumber(ArgSetWalker)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
+ gShellLevel1HiiHandle,
+ ArgSet,
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (ArgSetWalker[0] == L'-') {
@@ -459,7 +487,16 @@ ShellCommandRunFor ( ArgSetWalker++;
}
if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
+ gShellLevel1HiiHandle,
+ ArgSet,
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (ArgSetWalker[0] == L'-') {
@@ -479,7 +516,16 @@ ShellCommandRunFor ( }
if (ArgSetWalker != NULL && *ArgSetWalker != CHAR_NULL) {
if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
+ gShellLevel1HiiHandle,
+ ArgSet,
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (*ArgSetWalker == L')') {
@@ -492,7 +538,16 @@ ShellCommandRunFor ( }
if (StrStr(ArgSetWalker, L" ") != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
+ gShellLevel1HiiHandle,
+ ArgSet,
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER;
}
}
@@ -512,7 +567,16 @@ ShellCommandRunFor ( }
CurrentScriptFile->CurrentCommand->Data = Info;
} else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
+ gShellLevel1HiiHandle,
+ ArgSet,
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER;
}
} else {
@@ -553,7 +617,17 @@ ShellCommandRunFor ( // find the matching endfor (we're done with the loop)
//
if (!MoveToTag(GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, FALSE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"EndFor", L"For", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
+ gShellLevel1HiiHandle,
+ L"EndFor",
+ L"For",
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_DEVICE_ERROR;
}
if (Info->RemoveSubstAlias) {
@@ -611,7 +685,17 @@ ShellCommandRunFor ( // find the matching endfor (we're done with the loop)
//
if (!MoveToTag(GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, FALSE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"EndFor", L"For", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
+ gShellLevel1HiiHandle,
+ L"EndFor",
+ L"For",
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_DEVICE_ERROR;
}
if (Info->RemoveSubstAlias) {
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c index 3e5a59c575..4d48c7f1e9 100644 --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c +++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c @@ -33,6 +33,7 @@ ShellCommandRunGoto ( SHELL_STATUS ShellStatus;
CHAR16 *CompareString;
UINTN Size;
+ SCRIPT_FILE *CurrentScriptFile;
ShellStatus = SHELL_SUCCESS;
CompareString = NULL;
@@ -79,6 +80,7 @@ ShellCommandRunGoto ( // Check forwards and then backwards for a label...
//
if (!MoveToTag(GetNextNode, L"endfor", L"for", CompareString, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, TRUE)) {
+ CurrentScriptFile = ShellCommandGetCurrentScriptFile();
ShellPrintHiiEx(
-1,
-1,
@@ -87,9 +89,9 @@ ShellCommandRunGoto ( gShellLevel1HiiHandle,
CompareString,
L"Goto",
- ShellCommandGetCurrentScriptFile()!=NULL
- &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
- ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_NOT_FOUND;
}
FreePool(CompareString);
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);
}
|