diff options
author | Michael Kubacki <michael.kubacki@microsoft.com> | 2021-12-05 14:54:09 -0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2021-12-07 17:24:28 +0000 |
commit | ac0a286f4d747a4c6c603a7b225917293cbe1e9f (patch) | |
tree | 32654f2b35755afc961e2c97296b2dec5762da75 /OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c | |
parent | d1050b9dff1cace252aff86630bfdb59dff5f507 (diff) | |
download | edk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.tar.gz edk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.tar.bz2 edk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.zip |
OvmfPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737
Apply uncrustify changes to .c/.h files in the OvmfPkg 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: Andrew Fish <afish@apple.com>
Diffstat (limited to 'OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c')
-rw-r--r-- | OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c | 298 |
1 files changed, 194 insertions, 104 deletions
diff --git a/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c b/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c index 07baa0e8d1..40c464ce16 100644 --- a/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c +++ b/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c @@ -31,25 +31,25 @@ typedef struct { } SINGLE_NODE_VENDOR_MEDIA_DEVPATH;
#pragma pack ()
-STATIC EFI_HII_HANDLE mLinuxInitrdShellCommandHiiHandle;
-STATIC EFI_PHYSICAL_ADDRESS mInitrdFileAddress;
-STATIC UINTN mInitrdFileSize;
-STATIC EFI_HANDLE mInitrdLoadFile2Handle;
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-u", TypeFlag},
- {NULL, TypeMax}
- };
+STATIC EFI_HII_HANDLE mLinuxInitrdShellCommandHiiHandle;
+STATIC EFI_PHYSICAL_ADDRESS mInitrdFileAddress;
+STATIC UINTN mInitrdFileSize;
+STATIC EFI_HANDLE mInitrdLoadFile2Handle;
+
+STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
+ { L"-u", TypeFlag },
+ { NULL, TypeMax }
+};
-STATIC CONST SINGLE_NODE_VENDOR_MEDIA_DEVPATH mInitrdDevicePath = {
+STATIC CONST SINGLE_NODE_VENDOR_MEDIA_DEVPATH mInitrdDevicePath = {
{
{
- MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, { sizeof (VENDOR_DEVICE_PATH) }
+ MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP,{ sizeof (VENDOR_DEVICE_PATH) }
},
LINUX_EFI_INITRD_MEDIA_GUID
- }, {
+ },{
END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
- { sizeof (EFI_DEVICE_PATH_PROTOCOL) }
+ { sizeof (EFI_DEVICE_PATH_PROTOCOL) }
}
};
@@ -59,13 +59,16 @@ IsOtherInitrdDevicePathAlreadyInstalled ( VOID
)
{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_HANDLE Handle;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_HANDLE Handle;
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)&mInitrdDevicePath;
- Status = gBS->LocateDevicePath (&gEfiLoadFile2ProtocolGuid, &DevicePath,
- &Handle);
+ Status = gBS->LocateDevicePath (
+ &gEfiLoadFile2ProtocolGuid,
+ &DevicePath,
+ &Handle
+ );
if (EFI_ERROR (Status)) {
return FALSE;
}
@@ -77,6 +80,7 @@ IsOtherInitrdDevicePathAlreadyInstalled ( if (Handle == mInitrdLoadFile2Handle) {
return FALSE;
}
+
return TRUE;
}
@@ -84,28 +88,29 @@ STATIC EFI_STATUS
EFIAPI
InitrdLoadFile2 (
- IN EFI_LOAD_FILE2_PROTOCOL *This,
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
- IN BOOLEAN BootPolicy,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer OPTIONAL
+ IN EFI_LOAD_FILE2_PROTOCOL *This,
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ IN BOOLEAN BootPolicy,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer OPTIONAL
)
{
if (BootPolicy) {
return EFI_UNSUPPORTED;
}
- if (BufferSize == NULL || !IsDevicePathValid (FilePath, 0)) {
+ if ((BufferSize == NULL) || !IsDevicePathValid (FilePath, 0)) {
return EFI_INVALID_PARAMETER;
}
- if (FilePath->Type != END_DEVICE_PATH_TYPE ||
- FilePath->SubType != END_ENTIRE_DEVICE_PATH_SUBTYPE ||
- mInitrdFileSize == 0) {
+ if ((FilePath->Type != END_DEVICE_PATH_TYPE) ||
+ (FilePath->SubType != END_ENTIRE_DEVICE_PATH_SUBTYPE) ||
+ (mInitrdFileSize == 0))
+ {
return EFI_NOT_FOUND;
}
- if (Buffer == NULL || *BufferSize < mInitrdFileSize) {
+ if ((Buffer == NULL) || (*BufferSize < mInitrdFileSize)) {
*BufferSize = mInitrdFileSize;
return EFI_BUFFER_TOO_SMALL;
}
@@ -117,7 +122,7 @@ InitrdLoadFile2 ( return EFI_SUCCESS;
}
-STATIC CONST EFI_LOAD_FILE2_PROTOCOL mInitrdLoadFile2 = {
+STATIC CONST EFI_LOAD_FILE2_PROTOCOL mInitrdLoadFile2 = {
InitrdLoadFile2,
};
@@ -127,18 +132,24 @@ UninstallLoadFile2Protocol ( VOID
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (mInitrdLoadFile2Handle != NULL) {
- Status = gBS->UninstallMultipleProtocolInterfaces (mInitrdLoadFile2Handle,
- &gEfiDevicePathProtocolGuid, &mInitrdDevicePath,
- &gEfiLoadFile2ProtocolGuid, &mInitrdLoadFile2,
- NULL);
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ mInitrdLoadFile2Handle,
+ &gEfiDevicePathProtocolGuid,
+ &mInitrdDevicePath,
+ &gEfiLoadFile2ProtocolGuid,
+ &mInitrdLoadFile2,
+ NULL
+ );
if (!EFI_ERROR (Status)) {
mInitrdLoadFile2Handle = NULL;
}
+
return Status;
}
+
return EFI_SUCCESS;
}
@@ -157,42 +168,59 @@ FreeInitrdFile ( STATIC
EFI_STATUS
CacheInitrdFile (
- IN SHELL_FILE_HANDLE FileHandle
+ IN SHELL_FILE_HANDLE FileHandle
)
{
- EFI_STATUS Status;
- UINT64 FileSize;
- UINTN ReadSize;
+ EFI_STATUS Status;
+ UINT64 FileSize;
+ UINTN ReadSize;
Status = gEfiShellProtocol->GetFileSize (FileHandle, &FileSize);
if (EFI_ERROR (Status)) {
return Status;
}
- if (FileSize == 0 || FileSize > MAX_UINTN) {
+ if ((FileSize == 0) || (FileSize > MAX_UINTN)) {
return EFI_UNSUPPORTED;
}
- Status = gBS->AllocatePages (AllocateAnyPages, EfiLoaderData,
- EFI_SIZE_TO_PAGES ((UINTN)FileSize), &mInitrdFileAddress);
+ Status = gBS->AllocatePages (
+ AllocateAnyPages,
+ EfiLoaderData,
+ EFI_SIZE_TO_PAGES ((UINTN)FileSize),
+ &mInitrdFileAddress
+ );
if (EFI_ERROR (Status)) {
return Status;
}
ReadSize = (UINTN)FileSize;
- Status = gEfiShellProtocol->ReadFile (FileHandle, &ReadSize,
- (VOID *)(UINTN)mInitrdFileAddress);
- if (EFI_ERROR (Status) || ReadSize < FileSize) {
- DEBUG ((DEBUG_WARN, "%a: failed to read initrd file - %r 0x%lx 0x%lx\n",
- __FUNCTION__, Status, (UINT64)ReadSize, FileSize));
+ Status = gEfiShellProtocol->ReadFile (
+ FileHandle,
+ &ReadSize,
+ (VOID *)(UINTN)mInitrdFileAddress
+ );
+ if (EFI_ERROR (Status) || (ReadSize < FileSize)) {
+ DEBUG ((
+ DEBUG_WARN,
+ "%a: failed to read initrd file - %r 0x%lx 0x%lx\n",
+ __FUNCTION__,
+ Status,
+ (UINT64)ReadSize,
+ FileSize
+ ));
goto FreeMemory;
}
if (mInitrdLoadFile2Handle == NULL) {
- Status = gBS->InstallMultipleProtocolInterfaces (&mInitrdLoadFile2Handle,
- &gEfiDevicePathProtocolGuid, &mInitrdDevicePath,
- &gEfiLoadFile2ProtocolGuid, &mInitrdLoadFile2,
- NULL);
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &mInitrdLoadFile2Handle,
+ &gEfiDevicePathProtocolGuid,
+ &mInitrdDevicePath,
+ &gEfiLoadFile2ProtocolGuid,
+ &mInitrdLoadFile2,
+ NULL
+ );
ASSERT_EFI_ERROR (Status);
}
@@ -218,16 +246,16 @@ RunInitrd ( IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- CONST CHAR16 *Param;
- CHAR16 *Filename;
- SHELL_STATUS ShellStatus;
- SHELL_FILE_HANDLE FileHandle;
+ EFI_STATUS Status;
+ LIST_ENTRY *Package;
+ CHAR16 *ProblemParam;
+ CONST CHAR16 *Param;
+ CHAR16 *Filename;
+ SHELL_STATUS ShellStatus;
+ SHELL_FILE_HANDLE FileHandle;
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
+ ProblemParam = NULL;
+ ShellStatus = SHELL_SUCCESS;
Status = ShellInitialize ();
ASSERT_EFI_ERROR (Status);
@@ -237,30 +265,55 @@ RunInitrd ( //
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),
- mLinuxInitrdShellCommandHiiHandle, L"initrd", ProblemParam);
+ if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PROBLEM),
+ mLinuxInitrdShellCommandHiiHandle,
+ L"initrd",
+ ProblemParam
+ );
FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- ASSERT(FALSE);
+ ASSERT (FALSE);
}
} else if (IsOtherInitrdDevicePathAlreadyInstalled ()) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ALREADY_INSTALLED),
- mLinuxInitrdShellCommandHiiHandle, L"initrd");
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_ALREADY_INSTALLED),
+ mLinuxInitrdShellCommandHiiHandle,
+ L"initrd"
+ );
ShellStatus = SHELL_UNSUPPORTED;
} else {
if (ShellCommandLineGetCount (Package) > 2) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY),
- mLinuxInitrdShellCommandHiiHandle, L"initrd");
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_TOO_MANY),
+ mLinuxInitrdShellCommandHiiHandle,
+ L"initrd"
+ );
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount (Package) < 2) {
if (ShellCommandLineGetFlag (Package, L"-u")) {
FreeInitrdFile ();
UninstallLoadFile2Protocol ();
} else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW),
- mLinuxInitrdShellCommandHiiHandle, L"initrd");
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_TOO_FEW),
+ mLinuxInitrdShellCommandHiiHandle,
+ L"initrd"
+ );
ShellStatus = SHELL_INVALID_PARAMETER;
}
} else {
@@ -269,30 +322,50 @@ RunInitrd ( Filename = ShellFindFilePath (Param);
if (Filename == NULL) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FIND_FAIL),
- mLinuxInitrdShellCommandHiiHandle, L"initrd", Param);
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_FIND_FAIL),
+ mLinuxInitrdShellCommandHiiHandle,
+ L"initrd",
+ Param
+ );
ShellStatus = SHELL_NOT_FOUND;
} else {
- Status = ShellOpenFileByName (Filename, &FileHandle,
- EFI_FILE_MODE_READ, 0);
+ Status = ShellOpenFileByName (
+ Filename,
+ &FileHandle,
+ EFI_FILE_MODE_READ,
+ 0
+ );
if (!EFI_ERROR (Status)) {
FreeInitrdFile ();
Status = CacheInitrdFile (FileHandle);
ShellCloseFile (&FileHandle);
}
+
if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL),
- mLinuxInitrdShellCommandHiiHandle, L"initrd", Param);
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL),
+ mLinuxInitrdShellCommandHiiHandle,
+ L"initrd",
+ Param
+ );
ShellStatus = SHELL_NOT_FOUND;
}
+
FreePool (Filename);
}
}
}
+
return ShellStatus;
}
-
/**
This is the shell command handler function pointer callback type. This
function handles the command when it is invoked in the shell.
@@ -310,10 +383,10 @@ RunInitrd ( SHELL_STATUS
EFIAPI
LinuxInitrdCommandHandler (
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
- IN EFI_SYSTEM_TABLE *SystemTable,
- IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
- IN EFI_SHELL_PROTOCOL *Shell
+ IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
+ IN EFI_SYSTEM_TABLE *SystemTable,
+ IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
+ IN EFI_SHELL_PROTOCOL *Shell
)
{
gEfiShellParametersProtocol = ShellParameters;
@@ -338,15 +411,18 @@ STATIC CHAR16 *
EFIAPI
LinuxInitrdGetHelp (
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
- IN CONST CHAR8 *Language
+ IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
+ IN CONST CHAR8 *Language
)
{
- return HiiGetString (mLinuxInitrdShellCommandHiiHandle,
- STRING_TOKEN (STR_GET_HELP_INITRD), Language);
+ return HiiGetString (
+ mLinuxInitrdShellCommandHiiHandle,
+ STRING_TOKEN (STR_GET_HELP_INITRD),
+ Language
+ );
}
-STATIC EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mLinuxInitrdDynamicCommand = {
+STATIC EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mLinuxInitrdDynamicCommand = {
L"initrd",
LinuxInitrdCommandHandler,
LinuxInitrdGetHelp
@@ -362,19 +438,24 @@ STATIC EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mLinuxInitrdDynamicCommand = { STATIC
EFI_HII_HANDLE
InitializeHiiPackage (
- EFI_HANDLE ImageHandle
+ EFI_HANDLE ImageHandle
)
{
- EFI_STATUS Status;
- EFI_HII_PACKAGE_LIST_HEADER *PackageList;
- EFI_HII_HANDLE HiiHandle;
+ EFI_STATUS Status;
+ EFI_HII_PACKAGE_LIST_HEADER *PackageList;
+ EFI_HII_HANDLE HiiHandle;
//
// Retrieve HII package list from ImageHandle
//
- Status = gBS->OpenProtocol (ImageHandle, &gEfiHiiPackageListProtocolGuid,
- (VOID **)&PackageList, ImageHandle, NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ Status = gBS->OpenProtocol (
+ ImageHandle,
+ &gEfiHiiPackageListProtocolGuid,
+ (VOID **)&PackageList,
+ ImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
return NULL;
@@ -383,12 +464,17 @@ InitializeHiiPackage ( //
// Publish HII package list to HII Database.
//
- Status = gHiiDatabase->NewPackageList (gHiiDatabase, PackageList, NULL,
- &HiiHandle);
+ Status = gHiiDatabase->NewPackageList (
+ gHiiDatabase,
+ PackageList,
+ NULL,
+ &HiiHandle
+ );
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
return NULL;
}
+
return HiiHandle;
}
@@ -407,21 +493,23 @@ InitializeHiiPackage ( EFI_STATUS
EFIAPI
LinuxInitrdDynamicShellCommandEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
mLinuxInitrdShellCommandHiiHandle = InitializeHiiPackage (ImageHandle);
if (mLinuxInitrdShellCommandHiiHandle == NULL) {
return EFI_ABORTED;
}
- Status = gBS->InstallProtocolInterface (&ImageHandle,
+ Status = gBS->InstallProtocolInterface (
+ &ImageHandle,
&gEfiShellDynamicCommandProtocolGuid,
EFI_NATIVE_INTERFACE,
- &mLinuxInitrdDynamicCommand);
+ &mLinuxInitrdDynamicCommand
+ );
ASSERT_EFI_ERROR (Status);
return Status;
}
@@ -437,10 +525,10 @@ LinuxInitrdDynamicShellCommandEntryPoint ( EFI_STATUS
EFIAPI
LinuxInitrdDynamicShellCommandUnload (
- IN EFI_HANDLE ImageHandle
-)
+ IN EFI_HANDLE ImageHandle
+ )
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
FreeInitrdFile ();
@@ -449,9 +537,11 @@ LinuxInitrdDynamicShellCommandUnload ( return Status;
}
- Status = gBS->UninstallProtocolInterface (ImageHandle,
+ Status = gBS->UninstallProtocolInterface (
+ ImageHandle,
&gEfiShellDynamicCommandProtocolGuid,
- &mLinuxInitrdDynamicCommand);
+ &mLinuxInitrdDynamicCommand
+ );
if (EFI_ERROR (Status)) {
return Status;
}
|