ShellPkg: Clean-up 'map' command error message handling

Refactor 'map' command error handling code and add standard error message

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Tapan Shah <tapandshah@hpe.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19616 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Tapan Shah 2016-01-07 22:01:28 +00:00 committed by jcarsey
parent eb0e964936
commit e49ecad0fa
1 changed files with 40 additions and 41 deletions

View File

@ -1,8 +1,10 @@
/** @file
Main file for map shell level 2 command.
(C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -1196,51 +1198,48 @@ ShellCommandRunMap (
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", Mapping);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (MapAsHandle != NULL) {
TempStringLength = StrLen(SName);
if (!IsNumberLetterOnly(SName, TempStringLength-(SName[TempStringLength-1]==L':'?1:0))) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", SName);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
TempStringLength = StrLen(SName);
if (!IsNumberLetterOnly(SName, TempStringLength-(SName[TempStringLength-1]==L':'?1:0))) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", SName);
ShellStatus = SHELL_INVALID_PARAMETER;
}
if (ShellStatus == SHELL_SUCCESS) {
if (MapAsHandle != NULL) {
ShellStatus = AddMappingFromHandle(MapAsHandle, SName);
}
} else {
TempStringLength = StrLen(SName);
if (!IsNumberLetterOnly(SName, TempStringLength-(SName[TempStringLength-1]==L':'?1:0))) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", SName);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ShellStatus = AddMappingFromMapping(Mapping, SName);
}
if (ShellStatus != SHELL_SUCCESS) {
switch (ShellStatus) {
case SHELL_ACCESS_DENIED:
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellLevel2HiiHandle, L"map");
break;
case SHELL_INVALID_PARAMETER:
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", Mapping);
break;
case SHELL_DEVICE_ERROR:
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MAP_NOF), gShellLevel2HiiHandle, L"map", Mapping);
break;
default:
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", ShellStatus|MAX_BIT);
}
} else {
//
// now do the display...
//
ShellStatus = PerformMappingDisplay(
FALSE,
FALSE,
FALSE,
NULL,
SfoMode,
SName,
TRUE
);
} // we were sucessful so do an output
}
if (ShellStatus != SHELL_SUCCESS) {
switch (ShellStatus) {
case SHELL_ACCESS_DENIED:
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellLevel2HiiHandle, L"map");
break;
case SHELL_INVALID_PARAMETER:
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", Mapping);
break;
case SHELL_DEVICE_ERROR:
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MAP_NOF), gShellLevel2HiiHandle, L"map", Mapping);
break;
default:
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", ShellStatus|MAX_BIT);
}
} else {
//
// now do the display...
//
ShellStatus = PerformMappingDisplay(
FALSE,
FALSE,
FALSE,
NULL,
SfoMode,
SName,
TRUE
);
} // we were sucessful so do an output
} // got a valid map target
} // got 2 variables
} // we are adding a mapping