ShellPkg: Apply uncrustify changes

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the ShellPkg package

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
This commit is contained in:
Michael Kubacki
2021-12-05 14:54:13 -08:00
committed by mergify[bot]
parent c411b485b6
commit 47d20b54f9
211 changed files with 30269 additions and 27004 deletions

View File

@ -9,21 +9,21 @@
#include "UefiShellDebug1CommandsLib.h"
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-guid", TypeValue},
{L"-bs", TypeFlag},
{L"-rt", TypeFlag},
{L"-nv", TypeFlag},
{NULL, TypeMax}
};
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{ L"-guid", TypeValue },
{ L"-bs", TypeFlag },
{ L"-rt", TypeFlag },
{ L"-nv", TypeFlag },
{ NULL, TypeMax }
};
typedef enum {
DataTypeHexNumber = 0,
DataTypeHexArray = 1,
DataTypeAscii = 2,
DataTypeUnicode = 3,
DataTypeDevicePath = 4,
DataTypeUnKnow = 5
DataTypeHexNumber = 0,
DataTypeHexArray = 1,
DataTypeAscii = 2,
DataTypeUnicode = 3,
DataTypeDevicePath = 4,
DataTypeUnKnow = 5
} DATA_TYPE;
typedef union {
@ -49,13 +49,14 @@ IsStringOfHexNibbles (
IN CONST CHAR16 *String
)
{
CONST CHAR16 *Pos;
CONST CHAR16 *Pos;
for (Pos = String; *Pos != L'\0'; ++Pos) {
if (!ShellIsHexaDecimalDigitCharacter (*Pos)) {
return FALSE;
}
}
return TRUE;
}
@ -71,14 +72,14 @@ TestDataType (
IN CONST CHAR16 *Data
)
{
if (Data[0] == L'0' && (Data[1] == L'x' || Data[1] == L'X')) {
if (IsStringOfHexNibbles (Data+2) && StrLen (Data + 2) <= 16) {
if ((Data[0] == L'0') && ((Data[1] == L'x') || (Data[1] == L'X'))) {
if (IsStringOfHexNibbles (Data+2) && (StrLen (Data + 2) <= 16)) {
return DataTypeHexNumber;
} else {
return DataTypeUnKnow;
}
} else if (Data[0] == L'H') {
if (IsStringOfHexNibbles (Data + 1) && StrLen (Data + 1) % 2 == 0) {
if (IsStringOfHexNibbles (Data + 1) && (StrLen (Data + 1) % 2 == 0)) {
return DataTypeHexArray;
} else {
return DataTypeUnKnow;
@ -87,11 +88,11 @@ TestDataType (
return DataTypeAscii;
} else if (Data[0] == L'L') {
return DataTypeUnicode;
} else if (Data[0] == L'P' || StrnCmp (Data, L"--", 2) == 0) {
} else if ((Data[0] == L'P') || (StrnCmp (Data, L"--", 2) == 0)) {
return DataTypeDevicePath;
}
if (IsStringOfHexNibbles (Data) && StrLen (Data) % 2 == 0) {
if (IsStringOfHexNibbles (Data) && (StrLen (Data) % 2 == 0)) {
return DataTypeHexArray;
}
@ -114,9 +115,9 @@ TestDataType (
**/
EFI_STATUS
ParseParameterData (
IN CONST CHAR16 *Data,
OUT VOID *Buffer,
IN OUT UINTN *BufferSize
IN CONST CHAR16 *Data,
OUT VOID *Buffer,
IN OUT UINTN *BufferSize
)
{
UINT64 HexNumber;
@ -127,14 +128,14 @@ ParseParameterData (
EFI_DEVICE_PATH_PROTOCOL *DevPath;
EFI_STATUS Status;
HexNumber = 0;
HexNumberLen = 0;
Size = 0;
AsciiBuffer = NULL;
DevPath = NULL;
Status = EFI_SUCCESS;
HexNumber = 0;
HexNumberLen = 0;
Size = 0;
AsciiBuffer = NULL;
DevPath = NULL;
Status = EFI_SUCCESS;
if (Data == NULL || BufferSize == NULL) {
if ((Data == NULL) || (BufferSize == NULL)) {
return EFI_INVALID_PARAMETER;
}
@ -145,20 +146,22 @@ ParseParameterData (
//
StrHexToUint64S (Data + 2, NULL, &HexNumber);
HexNumberLen = StrLen (Data + 2);
if (HexNumberLen >= 1 && HexNumberLen <= 2) {
if ((HexNumberLen >= 1) && (HexNumberLen <= 2)) {
Size = 1;
} else if (HexNumberLen >= 3 && HexNumberLen <= 4) {
} else if ((HexNumberLen >= 3) && (HexNumberLen <= 4)) {
Size = 2;
} else if (HexNumberLen >= 5 && HexNumberLen <= 8) {
} else if ((HexNumberLen >= 5) && (HexNumberLen <= 8)) {
Size = 4;
} else if (HexNumberLen >= 9 && HexNumberLen <= 16) {
} else if ((HexNumberLen >= 9) && (HexNumberLen <= 16)) {
Size = 8;
}
if (Buffer != NULL && *BufferSize >= Size) {
CopyMem(Buffer, (VOID *)&HexNumber, Size);
if ((Buffer != NULL) && (*BufferSize >= Size)) {
CopyMem (Buffer, (VOID *)&HexNumber, Size);
} else {
Status = EFI_BUFFER_TOO_SMALL;
}
*BufferSize = Size;
} else if (DataType == DataTypeHexArray) {
//
@ -169,11 +172,12 @@ ParseParameterData (
}
Size = StrLen (Data) / 2;
if (Buffer != NULL && *BufferSize >= Size) {
StrHexToBytes(Data, StrLen (Data), (UINT8 *)Buffer, Size);
if ((Buffer != NULL) && (*BufferSize >= Size)) {
StrHexToBytes (Data, StrLen (Data), (UINT8 *)Buffer, Size);
} else {
Status = EFI_BUFFER_TOO_SMALL;
}
*BufferSize = Size;
} else if (DataType == DataTypeAscii) {
//
@ -182,6 +186,7 @@ ParseParameterData (
if (*Data == L'S') {
Data = Data + 1;
}
AsciiBuffer = AllocateZeroPool (StrSize (Data) / 2);
if (AsciiBuffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@ -189,13 +194,15 @@ ParseParameterData (
AsciiSPrint (AsciiBuffer, StrSize (Data) / 2, "%s", (CHAR8 *)Data);
Size = StrSize (Data) / 2 - 1;
if (Buffer != NULL && *BufferSize >= Size) {
if ((Buffer != NULL) && (*BufferSize >= Size)) {
CopyMem (Buffer, AsciiBuffer, Size);
} else {
Status = EFI_BUFFER_TOO_SMALL;
}
*BufferSize = Size;
}
SHELL_FREE_NON_NULL (AsciiBuffer);
} else if (DataType == DataTypeUnicode) {
//
@ -204,12 +211,14 @@ ParseParameterData (
if (*Data == L'L') {
Data = Data + 1;
}
Size = StrSize (Data) - sizeof (CHAR16);
if (Buffer != NULL && *BufferSize >= Size) {
if ((Buffer != NULL) && (*BufferSize >= Size)) {
CopyMem (Buffer, Data, Size);
} else {
Status = EFI_BUFFER_TOO_SMALL;
}
*BufferSize = Size;
} else if (DataType == DataTypeDevicePath) {
if (*Data == L'P') {
@ -217,19 +226,22 @@ ParseParameterData (
} else if (StrnCmp (Data, L"--", 2) == 0) {
Data = Data + 2;
}
DevPath = ConvertTextToDevicePath (Data);
if (DevPath == NULL) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_DPFT), gShellDebug1HiiHandle, L"setvar");
Status = EFI_INVALID_PARAMETER;
} else {
Size = GetDevicePathSize (DevPath);
if (Buffer != NULL && *BufferSize >= Size) {
if ((Buffer != NULL) && (*BufferSize >= Size)) {
CopyMem (Buffer, DevPath, Size);
} else {
Status = EFI_BUFFER_TOO_SMALL;
}
*BufferSize = Size;
}
SHELL_FREE_NON_NULL (DevPath);
} else {
Status = EFI_INVALID_PARAMETER;
@ -251,23 +263,23 @@ ParseParameterData (
**/
EFI_STATUS
GetVariableDataFromParameter (
IN CONST LIST_ENTRY *Package,
OUT UINT8 **Buffer,
OUT UINTN *BufferSize
IN CONST LIST_ENTRY *Package,
OUT UINT8 **Buffer,
OUT UINTN *BufferSize
)
{
CONST CHAR16 *TempData;
UINTN Index;
UINTN TotalSize;
UINTN Size;
UINT8 *BufferWalker;
EFI_STATUS Status;
CONST CHAR16 *TempData;
UINTN Index;
UINTN TotalSize;
UINTN Size;
UINT8 *BufferWalker;
EFI_STATUS Status;
TotalSize = 0;
Size = 0;
Status = EFI_SUCCESS;
TotalSize = 0;
Size = 0;
Status = EFI_SUCCESS;
if (BufferSize == NULL || Buffer == NULL || ShellCommandLineGetCount (Package) < 3) {
if ((BufferSize == NULL) || (Buffer == NULL) || (ShellCommandLineGetCount (Package) < 3)) {
return EFI_INVALID_PARAMETER;
}
@ -281,8 +293,8 @@ GetVariableDataFromParameter (
}
TempData = TempData + 1;
Size = 0;
Status = ParseParameterData (TempData, NULL, &Size);
Size = 0;
Status = ParseParameterData (TempData, NULL, &Size);
if (EFI_ERROR (Status)) {
if (Status == EFI_BUFFER_TOO_SMALL) {
//
@ -295,13 +307,14 @@ GetVariableDataFromParameter (
} else if (Status == EFI_NOT_FOUND) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_DPFT), gShellDebug1HiiHandle, L"setvar");
}
return Status;
}
}
}
*BufferSize = TotalSize;
*Buffer = AllocateZeroPool (TotalSize);
*Buffer = AllocateZeroPool (TotalSize);
if (*Buffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@ -311,11 +324,11 @@ GetVariableDataFromParameter (
TempData = ShellCommandLineGetRawValue (Package, Index);
TempData = TempData + 1;
Size = TotalSize;
Size = TotalSize;
Status = ParseParameterData (TempData, (VOID *)BufferWalker, &Size);
if (!EFI_ERROR (Status)) {
BufferWalker = BufferWalker + Size;
TotalSize = TotalSize - Size;
TotalSize = TotalSize - Size;
} else {
return Status;
}
@ -338,131 +351,139 @@ ShellCommandRunSetVar (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
RETURN_STATUS RStatus;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *VariableName;
EFI_GUID Guid;
CONST CHAR16 *StringGuid;
UINT32 Attributes;
VOID *Buffer;
UINTN Size;
UINTN LoopVar;
EFI_STATUS Status;
RETURN_STATUS RStatus;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *VariableName;
EFI_GUID Guid;
CONST CHAR16 *StringGuid;
UINT32 Attributes;
VOID *Buffer;
UINTN Size;
UINTN LoopVar;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
Buffer = NULL;
Size = 0;
Attributes = 0;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
Buffer = NULL;
Size = 0;
Attributes = 0;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
Status = ShellInitialize ();
ASSERT_EFI_ERROR (Status);
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
Status = CommandInit ();
ASSERT_EFI_ERROR (Status);
//
// parse the command line
//
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"setvar", ProblemParam);
FreePool(ProblemParam);
if (EFI_ERROR (Status)) {
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"setvar", ProblemParam);
FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
ASSERT (FALSE);
}
} else if (ShellCommandLineCheckDuplicate (Package,&ProblemParam) != EFI_SUCCESS) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DUPLICATE), gShellDebug1HiiHandle, L"setvar", ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineCheckDuplicate (Package, &ProblemParam) != EFI_SUCCESS) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_DUPLICATE), gShellDebug1HiiHandle, L"setvar", ProblemParam);
FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (ShellCommandLineGetCount(Package) < 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"setvar");
if (ShellCommandLineGetCount (Package) < 2) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"setvar");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
VariableName = ShellCommandLineGetRawValue(Package, 1);
if (!ShellCommandLineGetFlag(Package, L"-guid")){
CopyGuid(&Guid, &gEfiGlobalVariableGuid);
VariableName = ShellCommandLineGetRawValue (Package, 1);
if (!ShellCommandLineGetFlag (Package, L"-guid")) {
CopyGuid (&Guid, &gEfiGlobalVariableGuid);
} else {
StringGuid = ShellCommandLineGetValue(Package, L"-guid");
RStatus = StrToGuid (StringGuid, &Guid);
StringGuid = ShellCommandLineGetValue (Package, L"-guid");
RStatus = StrToGuid (StringGuid, &Guid);
if (RETURN_ERROR (RStatus) || (StringGuid[GUID_STRING_LENGTH] != L'\0')) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"setvar", StringGuid);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"setvar", StringGuid);
ShellStatus = SHELL_INVALID_PARAMETER;
}
}
if (ShellCommandLineGetCount(Package) == 2) {
if (ShellCommandLineGetCount (Package) == 2) {
//
// Display
//
Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes, &Size, Buffer);
Status = gRT->GetVariable ((CHAR16 *)VariableName, &Guid, &Attributes, &Size, Buffer);
if (Status == EFI_BUFFER_TOO_SMALL) {
Buffer = AllocateZeroPool(Size);
Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes, &Size, Buffer);
Buffer = AllocateZeroPool (Size);
Status = gRT->GetVariable ((CHAR16 *)VariableName, &Guid, &Attributes, &Size, Buffer);
}
if (!EFI_ERROR(Status) && Buffer != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_SETVAR_PRINT), gShellDebug1HiiHandle, &Guid, VariableName, Size);
if (!EFI_ERROR (Status) && (Buffer != NULL)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SETVAR_PRINT), gShellDebug1HiiHandle, &Guid, VariableName, Size);
for (LoopVar = 0; LoopVar < Size; LoopVar++) {
ShellPrintEx(-1, -1, L"%02x ", ((UINT8*)Buffer)[LoopVar]);
ShellPrintEx (-1, -1, L"%02x ", ((UINT8 *)Buffer)[LoopVar]);
}
ShellPrintEx(-1, -1, L"\r\n");
ShellPrintEx (-1, -1, L"\r\n");
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_GET), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName);
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_GET), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName);
ShellStatus = SHELL_ACCESS_DENIED;
}
} else {
//
// Create, Delete or Modify.
//
Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes, &Size, Buffer);
Status = gRT->GetVariable ((CHAR16 *)VariableName, &Guid, &Attributes, &Size, Buffer);
if (Status == EFI_BUFFER_TOO_SMALL) {
Buffer = AllocateZeroPool(Size);
Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes, &Size, Buffer);
Buffer = AllocateZeroPool (Size);
Status = gRT->GetVariable ((CHAR16 *)VariableName, &Guid, &Attributes, &Size, Buffer);
}
if (EFI_ERROR(Status) || Buffer == NULL) {
if (EFI_ERROR (Status) || (Buffer == NULL)) {
//
// Creating a new variable. determine attributes from command line.
//
Attributes = 0;
if (ShellCommandLineGetFlag(Package, L"-bs")) {
if (ShellCommandLineGetFlag (Package, L"-bs")) {
Attributes |= EFI_VARIABLE_BOOTSERVICE_ACCESS;
}
if (ShellCommandLineGetFlag(Package, L"-rt")) {
if (ShellCommandLineGetFlag (Package, L"-rt")) {
Attributes |= EFI_VARIABLE_RUNTIME_ACCESS |
EFI_VARIABLE_BOOTSERVICE_ACCESS;
}
if (ShellCommandLineGetFlag(Package, L"-nv")) {
if (ShellCommandLineGetFlag (Package, L"-nv")) {
Attributes |= EFI_VARIABLE_NON_VOLATILE;
}
}
SHELL_FREE_NON_NULL(Buffer);
Size = 0;
Status = GetVariableDataFromParameter(Package, (UINT8 **)&Buffer, &Size);
if (!EFI_ERROR(Status)) {
Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, Size, Buffer);
SHELL_FREE_NON_NULL (Buffer);
Size = 0;
Status = GetVariableDataFromParameter (Package, (UINT8 **)&Buffer, &Size);
if (!EFI_ERROR (Status)) {
Status = gRT->SetVariable ((CHAR16 *)VariableName, &Guid, Attributes, Size, Buffer);
}
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName);
ShellStatus = SHELL_ACCESS_DENIED;
} else {
ASSERT(ShellStatus == SHELL_SUCCESS);
ASSERT (ShellStatus == SHELL_SUCCESS);
}
}
}
ShellCommandLineFreeVarList (Package);
}
if (Buffer != NULL) {
FreePool(Buffer);
FreePool (Buffer);
}
return (ShellStatus);