]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/DxeServicesLib/DxeServicesLib.c
MdePkg: Apply uncrustify changes
[mirror_edk2.git] / MdePkg / Library / DxeServicesLib / DxeServicesLib.c
index d4f366425fed300127832c4386beded29e5ec533..8f5a15dedc9f2fb13e0dff30ec8d340a07518cb7 100644 (file)
@@ -4,13 +4,7 @@
 \r
   Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
   (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -31,7 +25,7 @@
 /**\r
   Identify the device handle from which the Image is loaded from. As this device handle is passed to\r
   GetSectionFromFv as the identifier for a Firmware Volume, an EFI_FIRMWARE_VOLUME2_PROTOCOL\r
-  protocol instance should be located succesfully by calling gBS->HandleProtocol ().\r
+  protocol instance should be located successfully by calling gBS->HandleProtocol ().\r
 \r
   This function locates the EFI_LOADED_IMAGE_PROTOCOL instance installed\r
   on ImageHandle. It then returns EFI_LOADED_IMAGE_PROTOCOL.DeviceHandle.\r
 **/\r
 EFI_HANDLE\r
 InternalImageHandleToFvHandle (\r
-  EFI_HANDLE ImageHandle\r
+  EFI_HANDLE  ImageHandle\r
   )\r
 {\r
-  EFI_STATUS                    Status;\r
-  EFI_LOADED_IMAGE_PROTOCOL     *LoadedImage;\r
+  EFI_STATUS                 Status;\r
+  EFI_LOADED_IMAGE_PROTOCOL  *LoadedImage;\r
 \r
   ASSERT (ImageHandle != NULL);\r
 \r
   Status = gBS->HandleProtocol (\r
-             (EFI_HANDLE *) ImageHandle,\r
-             &gEfiLoadedImageProtocolGuid,\r
-             (VOID **) &LoadedImage\r
-             );\r
+                  ImageHandle,\r
+                  &gEfiLoadedImageProtocolGuid,\r
+                  (VOID **)&LoadedImage\r
+                  );\r
 \r
   ASSERT_EFI_ERROR (Status);\r
 \r
@@ -69,7 +63,6 @@ InternalImageHandleToFvHandle (
   // protocol is installed.\r
   //\r
   return LoadedImage->DeviceHandle;\r
-\r
 }\r
 \r
 /**\r
@@ -77,7 +70,7 @@ InternalImageHandleToFvHandle (
   Section type and instance number from the specified Firmware Volume.\r
 \r
   This functions first locate the EFI_FIRMWARE_VOLUME2_PROTOCOL protocol instance on FvHandle in order to\r
-  carry out the Firmware Volume read operation. The function then reads the Firmware Section found sepcifed\r
+  carry out the Firmware Volume read operation. The function then reads the Firmware Section found specified\r
   by NameGuid, SectionType and SectionInstance.\r
 \r
   The details of this search order is defined in description of EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection ()\r
@@ -100,7 +93,7 @@ InternalImageHandleToFvHandle (
   @param  SectionType             The Firmware Section type.\r
   @param  SectionInstance         The instance number of Firmware Section to\r
                                   read from starting from 0.\r
-  @param  Buffer                  On output, Buffer contains the the data read\r
+  @param  Buffer                  On output, Buffer contains the data read\r
                                   from the section in the Firmware File found.\r
   @param  Size                    On output, the size of Buffer.\r
 \r
@@ -117,17 +110,17 @@ InternalImageHandleToFvHandle (
 **/\r
 EFI_STATUS\r
 InternalGetSectionFromFv (\r
-  IN  EFI_HANDLE                    FvHandle,\r
-  IN  CONST EFI_GUID                *NameGuid,\r
-  IN  EFI_SECTION_TYPE              SectionType,\r
-  IN  UINTN                         SectionInstance,\r
-  OUT VOID                          **Buffer,\r
-  OUT UINTN                         *Size\r
+  IN  EFI_HANDLE        FvHandle,\r
+  IN  CONST EFI_GUID    *NameGuid,\r
+  IN  EFI_SECTION_TYPE  SectionType,\r
+  IN  UINTN             SectionInstance,\r
+  OUT VOID              **Buffer,\r
+  OUT UINTN             *Size\r
   )\r
 {\r
-  EFI_STATUS                    Status;\r
-  EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r
-  UINT32                        AuthenticationStatus;\r
+  EFI_STATUS                     Status;\r
+  EFI_FIRMWARE_VOLUME2_PROTOCOL  *Fv;\r
+  UINT32                         AuthenticationStatus;\r
 \r
   ASSERT (NameGuid != NULL);\r
   ASSERT (Buffer != NULL);\r
@@ -143,7 +136,7 @@ InternalGetSectionFromFv (
   Status = gBS->HandleProtocol (\r
                   FvHandle,\r
                   &gEfiFirmwareVolume2ProtocolGuid,\r
-                  (VOID **) &Fv\r
+                  (VOID **)&Fv\r
                   );\r
   if (EFI_ERROR (Status)) {\r
     return EFI_NOT_FOUND;\r
@@ -152,17 +145,17 @@ InternalGetSectionFromFv (
   //\r
   // Read desired section content in NameGuid file\r
   //\r
-  *Buffer     = NULL;\r
-  *Size       = 0;\r
-  Status      = Fv->ReadSection (\r
-                      Fv,\r
-                      NameGuid,\r
-                      SectionType,\r
-                      SectionInstance,\r
-                      Buffer,\r
-                      Size,\r
-                      &AuthenticationStatus\r
-                      );\r
+  *Buffer = NULL;\r
+  *Size   = 0;\r
+  Status  = Fv->ReadSection (\r
+                  Fv,\r
+                  NameGuid,\r
+                  SectionType,\r
+                  SectionInstance,\r
+                  Buffer,\r
+                  Size,\r
+                  &AuthenticationStatus\r
+                  );\r
 \r
   if (EFI_ERROR (Status) && (SectionType == EFI_SECTION_TE)) {\r
     //\r
@@ -235,35 +228,38 @@ InternalGetSectionFromFv (
 EFI_STATUS\r
 EFIAPI\r
 GetSectionFromAnyFvByFileType  (\r
-  IN  EFI_FV_FILETYPE               FileType,\r
-  IN  UINTN                         FileInstance,\r
-  IN  EFI_SECTION_TYPE              SectionType,\r
-  IN  UINTN                         SectionInstance,\r
-  OUT VOID                          **Buffer,\r
-  OUT UINTN                         *Size\r
+  IN  EFI_FV_FILETYPE   FileType,\r
+  IN  UINTN             FileInstance,\r
+  IN  EFI_SECTION_TYPE  SectionType,\r
+  IN  UINTN             SectionInstance,\r
+  OUT VOID              **Buffer,\r
+  OUT UINTN             *Size\r
   )\r
 {\r
-  EFI_STATUS                    Status;\r
-  EFI_HANDLE                    *HandleBuffer;\r
-  UINTN                         HandleCount;\r
-  UINTN                         IndexFv;\r
-  UINTN                         IndexFile;\r
-  UINTN                         Key;\r
-  EFI_GUID                      NameGuid;\r
-  EFI_FV_FILE_ATTRIBUTES        Attributes;\r
-  EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r
+  EFI_STATUS                     Status;\r
+  EFI_HANDLE                     *HandleBuffer;\r
+  UINTN                          HandleCount;\r
+  UINTN                          IndexFv;\r
+  UINTN                          IndexFile;\r
+  UINTN                          Key;\r
+  EFI_GUID                       NameGuid;\r
+  EFI_FV_FILE_ATTRIBUTES         Attributes;\r
+  EFI_FIRMWARE_VOLUME2_PROTOCOL  *Fv;\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (Size != NULL);\r
 \r
   //\r
   // Locate all available FVs.\r
   //\r
   HandleBuffer = NULL;\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiFirmwareVolume2ProtocolGuid,\r
-                  NULL,\r
-                  &HandleCount,\r
-                  &HandleBuffer\r
-                  );\r
+  Status       = gBS->LocateHandleBuffer (\r
+                        ByProtocol,\r
+                        &gEfiFirmwareVolume2ProtocolGuid,\r
+                        NULL,\r
+                        &HandleCount,\r
+                        &HandleBuffer\r
+                        );\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
@@ -285,13 +281,14 @@ GetSectionFromAnyFvByFileType  (
     // Use Firmware Volume 2 Protocol to search for a file of type FileType in all FVs.\r
     //\r
     IndexFile = FileInstance + 1;\r
-    Key = 0;\r
+    Key       = 0;\r
     do {\r
       Status = Fv->GetNextFile (Fv, &Key, &FileType, &NameGuid, &Attributes, Size);\r
       if (EFI_ERROR (Status)) {\r
         break;\r
       }\r
-      IndexFile --;\r
+\r
+      IndexFile--;\r
     } while (IndexFile > 0);\r
 \r
     //\r
@@ -323,7 +320,7 @@ GetSectionFromAnyFvByFileType  (
 \r
 Done:\r
   if (HandleBuffer != NULL) {\r
-    FreePool(HandleBuffer);\r
+    FreePool (HandleBuffer);\r
   }\r
 \r
   return Status;\r
@@ -375,18 +372,18 @@ Done:
 EFI_STATUS\r
 EFIAPI\r
 GetSectionFromAnyFv  (\r
-  IN CONST  EFI_GUID           *NameGuid,\r
-  IN        EFI_SECTION_TYPE   SectionType,\r
-  IN        UINTN              SectionInstance,\r
-  OUT       VOID               **Buffer,\r
-  OUT       UINTN              *Size\r
+  IN CONST  EFI_GUID          *NameGuid,\r
+  IN        EFI_SECTION_TYPE  SectionType,\r
+  IN        UINTN             SectionInstance,\r
+  OUT       VOID              **Buffer,\r
+  OUT       UINTN             *Size\r
   )\r
 {\r
-  EFI_STATUS                    Status;\r
-  EFI_HANDLE                    *HandleBuffer;\r
-  UINTN                         HandleCount;\r
-  UINTN                         Index;\r
-  EFI_HANDLE                    FvHandle;\r
+  EFI_STATUS  Status;\r
+  EFI_HANDLE  *HandleBuffer;\r
+  UINTN       HandleCount;\r
+  UINTN       Index;\r
+  EFI_HANDLE  FvHandle;\r
 \r
   //\r
   // Search the FV that contain the caller's FFS first.\r
@@ -395,26 +392,26 @@ GetSectionFromAnyFv  (
   // will locate the FFS faster.\r
   //\r
   FvHandle = InternalImageHandleToFvHandle (gImageHandle);\r
-  Status = InternalGetSectionFromFv (\r
-             FvHandle,\r
-             NameGuid,\r
-             SectionType,\r
-             SectionInstance,\r
-             Buffer,\r
-             Size\r
-             );\r
+  Status   = InternalGetSectionFromFv (\r
+               FvHandle,\r
+               NameGuid,\r
+               SectionType,\r
+               SectionInstance,\r
+               Buffer,\r
+               Size\r
+               );\r
   if (!EFI_ERROR (Status)) {\r
     return EFI_SUCCESS;\r
   }\r
 \r
   HandleBuffer = NULL;\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiFirmwareVolume2ProtocolGuid,\r
-                  NULL,\r
-                  &HandleCount,\r
-                  &HandleBuffer\r
-                  );\r
+  Status       = gBS->LocateHandleBuffer (\r
+                        ByProtocol,\r
+                        &gEfiFirmwareVolume2ProtocolGuid,\r
+                        NULL,\r
+                        &HandleCount,\r
+                        &HandleBuffer\r
+                        );\r
   if (EFI_ERROR (Status)) {\r
     goto Done;\r
   }\r
@@ -437,7 +434,6 @@ GetSectionFromAnyFv  (
         goto Done;\r
       }\r
     }\r
-\r
   }\r
 \r
   if (Index == HandleCount) {\r
@@ -447,10 +443,10 @@ GetSectionFromAnyFv  (
 Done:\r
 \r
   if (HandleBuffer != NULL) {\r
-    FreePool(HandleBuffer);\r
+    FreePool (HandleBuffer);\r
   }\r
-  return Status;\r
 \r
+  return Status;\r
 }\r
 \r
 /**\r
@@ -501,15 +497,15 @@ Done:
 EFI_STATUS\r
 EFIAPI\r
 GetSectionFromFv (\r
-  IN  CONST EFI_GUID                *NameGuid,\r
-  IN  EFI_SECTION_TYPE              SectionType,\r
-  IN  UINTN                         SectionInstance,\r
-  OUT VOID                          **Buffer,\r
-  OUT UINTN                         *Size\r
-    )\r
+  IN  CONST EFI_GUID    *NameGuid,\r
+  IN  EFI_SECTION_TYPE  SectionType,\r
+  IN  UINTN             SectionInstance,\r
+  OUT VOID              **Buffer,\r
+  OUT UINTN             *Size\r
+  )\r
 {\r
   return InternalGetSectionFromFv (\r
-           InternalImageHandleToFvHandle(gImageHandle),\r
+           InternalImageHandleToFvHandle (gImageHandle),\r
            NameGuid,\r
            SectionType,\r
            SectionInstance,\r
@@ -518,9 +514,8 @@ GetSectionFromFv (
            );\r
 }\r
 \r
-\r
 /**\r
-  Searches the FFS file the the currently executing module was loaded from and returns the first matching FFS section.\r
+  Searches the FFS file the currently executing module was loaded from and returns the first matching FFS section.\r
 \r
   This function searches the FFS file that the currently executing module was loaded from for a FFS sections of type SectionType.\r
   If the FFS file contains at least SectionInstance instances of the FFS section specified by SectionType,\r
@@ -564,14 +559,14 @@ GetSectionFromFv (
 EFI_STATUS\r
 EFIAPI\r
 GetSectionFromFfs (\r
-  IN  EFI_SECTION_TYPE              SectionType,\r
-  IN  UINTN                         SectionInstance,\r
-  OUT VOID                          **Buffer,\r
-  OUT UINTN                         *Size\r
-    )\r
+  IN  EFI_SECTION_TYPE  SectionType,\r
+  IN  UINTN             SectionInstance,\r
+  OUT VOID              **Buffer,\r
+  OUT UINTN             *Size\r
+  )\r
 {\r
-  return InternalGetSectionFromFv(\r
-           InternalImageHandleToFvHandle(gImageHandle),\r
+  return InternalGetSectionFromFv (\r
+           InternalImageHandleToFvHandle (gImageHandle),\r
            &gEfiCallerIdGuid,\r
            SectionType,\r
            SectionInstance,\r
@@ -580,7 +575,6 @@ GetSectionFromFfs (
            );\r
 }\r
 \r
-\r
 /**\r
   Get the image file buffer data and buffer size by its device path.\r
 \r
@@ -600,7 +594,7 @@ GetSectionFromFfs (
                                         selection. If FALSE, then FilePath must\r
                                         match an exact file to be loaded.\r
   @param[in]       FilePath             The pointer to the device path of the file\r
-                                        that is absracted to the file buffer.\r
+                                        that is abstracted to the file buffer.\r
   @param[out]      FileSize             The pointer to the size of the abstracted\r
                                         file buffer.\r
   @param[out]      AuthenticationStatus Pointer to the authentication status.\r
@@ -611,48 +605,48 @@ GetSectionFromFfs (
 VOID *\r
 EFIAPI\r
 GetFileBufferByFilePath (\r
-  IN BOOLEAN                           BootPolicy,\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL    *FilePath,\r
-  OUT      UINTN                       *FileSize,\r
-  OUT UINT32                           *AuthenticationStatus\r
+  IN BOOLEAN                         BootPolicy,\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *FilePath,\r
+  OUT      UINTN                     *FileSize,\r
+  OUT UINT32                         *AuthenticationStatus\r
   )\r
 {\r
-  EFI_DEVICE_PATH_PROTOCOL          *DevicePathNode;\r
-  EFI_DEVICE_PATH_PROTOCOL          *OrigDevicePathNode;\r
-  EFI_DEVICE_PATH_PROTOCOL          *TempDevicePathNode;\r
-  EFI_HANDLE                        Handle;\r
-  EFI_GUID                          *FvNameGuid;\r
-  EFI_FIRMWARE_VOLUME2_PROTOCOL     *FwVol;\r
-  EFI_SECTION_TYPE                  SectionType;\r
-  UINT8                             *ImageBuffer;\r
-  UINTN                             ImageBufferSize;\r
-  EFI_FV_FILETYPE                   Type;\r
-  EFI_FV_FILE_ATTRIBUTES            Attrib;\r
-  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL   *Volume;\r
-  EFI_FILE_HANDLE                   FileHandle;\r
-  EFI_FILE_HANDLE                   LastHandle;\r
-  EFI_FILE_INFO                     *FileInfo;\r
-  UINTN                             FileInfoSize;\r
-  EFI_LOAD_FILE_PROTOCOL            *LoadFile;\r
-  EFI_LOAD_FILE2_PROTOCOL           *LoadFile2;\r
-  EFI_STATUS                        Status;\r
+  EFI_DEVICE_PATH_PROTOCOL         *DevicePathNode;\r
+  EFI_DEVICE_PATH_PROTOCOL         *OrigDevicePathNode;\r
+  EFI_DEVICE_PATH_PROTOCOL         *TempDevicePathNode;\r
+  EFI_HANDLE                       Handle;\r
+  EFI_GUID                         *FvNameGuid;\r
+  EFI_FIRMWARE_VOLUME2_PROTOCOL    *FwVol;\r
+  EFI_SECTION_TYPE                 SectionType;\r
+  UINT8                            *ImageBuffer;\r
+  UINTN                            ImageBufferSize;\r
+  EFI_FV_FILETYPE                  Type;\r
+  EFI_FV_FILE_ATTRIBUTES           Attrib;\r
+  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL  *Volume;\r
+  EFI_FILE_HANDLE                  FileHandle;\r
+  EFI_FILE_HANDLE                  LastHandle;\r
+  EFI_FILE_INFO                    *FileInfo;\r
+  UINTN                            FileInfoSize;\r
+  EFI_LOAD_FILE_PROTOCOL           *LoadFile;\r
+  EFI_LOAD_FILE2_PROTOCOL          *LoadFile2;\r
+  EFI_STATUS                       Status;\r
 \r
   //\r
   // Check input File device path.\r
   //\r
-  if (FilePath == NULL || FileSize == NULL || AuthenticationStatus == NULL) {\r
+  if ((FilePath == NULL) || (FileSize == NULL) || (AuthenticationStatus == NULL)) {\r
     return NULL;\r
   }\r
 \r
   //\r
   // Init local variable\r
   //\r
-  TempDevicePathNode  = NULL;\r
-  FvNameGuid          = NULL;\r
-  FileInfo            = NULL;\r
-  FileHandle          = NULL;\r
-  ImageBuffer         = NULL;\r
-  ImageBufferSize     = 0;\r
+  TempDevicePathNode    = NULL;\r
+  FvNameGuid            = NULL;\r
+  FileInfo              = NULL;\r
+  FileHandle            = NULL;\r
+  ImageBuffer           = NULL;\r
+  ImageBufferSize       = 0;\r
   *AuthenticationStatus = 0;\r
 \r
   //\r
@@ -668,31 +662,31 @@ GetFileBufferByFilePath (
   // Is so, this device path may contain a Image.\r
   //\r
   DevicePathNode = OrigDevicePathNode;\r
-  Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &DevicePathNode, &Handle);\r
+  Status         = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &DevicePathNode, &Handle);\r
   if (!EFI_ERROR (Status)) {\r
     //\r
     // For FwVol File system there is only a single file name that is a GUID.\r
     //\r
-    FvNameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevicePathNode);\r
+    FvNameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)DevicePathNode);\r
     if (FvNameGuid == NULL) {\r
       Status = EFI_INVALID_PARAMETER;\r
     } else {\r
       //\r
       // Read image from the firmware file\r
       //\r
-      Status = gBS->HandleProtocol (Handle, &gEfiFirmwareVolume2ProtocolGuid, (VOID**)&FwVol);\r
+      Status = gBS->HandleProtocol (Handle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&FwVol);\r
       if (!EFI_ERROR (Status)) {\r
         SectionType = EFI_SECTION_PE32;\r
         ImageBuffer = NULL;\r
-        Status = FwVol->ReadSection (\r
-                          FwVol,\r
-                          FvNameGuid,\r
-                          SectionType,\r
-                          0,\r
-                          (VOID **)&ImageBuffer,\r
-                          &ImageBufferSize,\r
-                          AuthenticationStatus\r
-                          );\r
+        Status      = FwVol->ReadSection (\r
+                               FwVol,\r
+                               FvNameGuid,\r
+                               SectionType,\r
+                               0,\r
+                               (VOID **)&ImageBuffer,\r
+                               &ImageBufferSize,\r
+                               AuthenticationStatus\r
+                               );\r
         if (EFI_ERROR (Status)) {\r
           //\r
           // Try a raw file, since a PE32 SECTION does not exist\r
@@ -701,19 +695,21 @@ GetFileBufferByFilePath (
             FreePool (ImageBuffer);\r
             *AuthenticationStatus = 0;\r
           }\r
+\r
           ImageBuffer = NULL;\r
-          Status = FwVol->ReadFile (\r
-                            FwVol,\r
-                            FvNameGuid,\r
-                            (VOID **)&ImageBuffer,\r
-                            &ImageBufferSize,\r
-                            &Type,\r
-                            &Attrib,\r
-                            AuthenticationStatus\r
-                            );\r
+          Status      = FwVol->ReadFile (\r
+                                 FwVol,\r
+                                 FvNameGuid,\r
+                                 (VOID **)&ImageBuffer,\r
+                                 &ImageBufferSize,\r
+                                 &Type,\r
+                                 &Attrib,\r
+                                 AuthenticationStatus\r
+                                 );\r
         }\r
       }\r
     }\r
+\r
     if (!EFI_ERROR (Status)) {\r
       goto Finish;\r
     }\r
@@ -723,9 +719,9 @@ GetFileBufferByFilePath (
   // Attempt to access the file via a file system interface\r
   //\r
   DevicePathNode = OrigDevicePathNode;\r
-  Status = gBS->LocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, &DevicePathNode, &Handle);\r
+  Status         = gBS->LocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, &DevicePathNode, &Handle);\r
   if (!EFI_ERROR (Status)) {\r
-    Status = gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID**)&Volume);\r
+    Status = gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Volume);\r
     if (!EFI_ERROR (Status)) {\r
       //\r
       // Open the Volume to get the File System handle\r
@@ -746,15 +742,17 @@ GetFileBufferByFilePath (
           //\r
           Status = EFI_OUT_OF_RESOURCES;\r
         }\r
+\r
         //\r
         // Parse each MEDIA_FILEPATH_DP node. There may be more than one, since the\r
-        // directory information and filename can be seperate. The goal is to inch\r
+        // directory information and filename can be separate. The goal is to inch\r
         // our way down each device path node and close the previous node\r
         //\r
         DevicePathNode = TempDevicePathNode;\r
         while (!EFI_ERROR (Status) && !IsDevicePathEnd (DevicePathNode)) {\r
-          if (DevicePathType (DevicePathNode) != MEDIA_DEVICE_PATH ||\r
-              DevicePathSubType (DevicePathNode) != MEDIA_FILEPATH_DP) {\r
+          if ((DevicePathType (DevicePathNode) != MEDIA_DEVICE_PATH) ||\r
+              (DevicePathSubType (DevicePathNode) != MEDIA_FILEPATH_DP))\r
+          {\r
             Status = EFI_UNSUPPORTED;\r
             break;\r
           }\r
@@ -763,12 +761,12 @@ GetFileBufferByFilePath (
           FileHandle = NULL;\r
 \r
           Status = LastHandle->Open (\r
-                                LastHandle,\r
-                                &FileHandle,\r
-                                ((FILEPATH_DEVICE_PATH *) DevicePathNode)->PathName,\r
-                                EFI_FILE_MODE_READ,\r
-                                0\r
-                                );\r
+                                 LastHandle,\r
+                                 &FileHandle,\r
+                                 ((FILEPATH_DEVICE_PATH *)DevicePathNode)->PathName,\r
+                                 EFI_FILE_MODE_READ,\r
+                                 0\r
+                                 );\r
 \r
           //\r
           // Close the previous node\r
@@ -783,14 +781,14 @@ GetFileBufferByFilePath (
           // We have found the file. Now we need to read it. Before we can read the file we need to\r
           // figure out how big the file is.\r
           //\r
-          FileInfo = NULL;\r
+          FileInfo     = NULL;\r
           FileInfoSize = 0;\r
-          Status = FileHandle->GetInfo (\r
-                                FileHandle,\r
-                                &gEfiFileInfoGuid,\r
-                                &FileInfoSize,\r
-                                FileInfo\r
-                                );\r
+          Status       = FileHandle->GetInfo (\r
+                                       FileHandle,\r
+                                       &gEfiFileInfoGuid,\r
+                                       &FileInfoSize,\r
+                                       FileInfo\r
+                                       );\r
 \r
           if (Status == EFI_BUFFER_TOO_SMALL) {\r
             FileInfo = AllocatePool (FileInfoSize);\r
@@ -798,11 +796,11 @@ GetFileBufferByFilePath (
               Status = EFI_OUT_OF_RESOURCES;\r
             } else {\r
               Status = FileHandle->GetInfo (\r
-                                    FileHandle,\r
-                                    &gEfiFileInfoGuid,\r
-                                    &FileInfoSize,\r
-                                    FileInfo\r
-                                    );\r
+                                     FileHandle,\r
+                                     &gEfiFileInfoGuid,\r
+                                     &FileInfoSize,\r
+                                     FileInfo\r
+                                     );\r
             }\r
           }\r
 \r
@@ -824,20 +822,24 @@ GetFileBufferByFilePath (
             }\r
           }\r
         }\r
+\r
         //\r
         // Close the file and Free FileInfo and TempDevicePathNode since we are done\r
         //\r
         if (FileInfo != NULL) {\r
           FreePool (FileInfo);\r
         }\r
+\r
         if (FileHandle != NULL) {\r
           FileHandle->Close (FileHandle);\r
         }\r
+\r
         if (TempDevicePathNode != NULL) {\r
           FreePool (TempDevicePathNode);\r
         }\r
       }\r
     }\r
+\r
     if (!EFI_ERROR (Status)) {\r
       goto Finish;\r
     }\r
@@ -848,37 +850,38 @@ GetFileBufferByFilePath (
   //\r
   if (!BootPolicy) {\r
     DevicePathNode = OrigDevicePathNode;\r
-    Status = gBS->LocateDevicePath (&gEfiLoadFile2ProtocolGuid, &DevicePathNode, &Handle);\r
+    Status         = gBS->LocateDevicePath (&gEfiLoadFile2ProtocolGuid, &DevicePathNode, &Handle);\r
     if (!EFI_ERROR (Status)) {\r
-      Status = gBS->HandleProtocol (Handle, &gEfiLoadFile2ProtocolGuid, (VOID**)&LoadFile2);\r
+      Status = gBS->HandleProtocol (Handle, &gEfiLoadFile2ProtocolGuid, (VOID **)&LoadFile2);\r
       if (!EFI_ERROR (Status)) {\r
         //\r
         // Call LoadFile2 with the correct buffer size\r
         //\r
         ImageBufferSize = 0;\r
         ImageBuffer     = NULL;\r
-        Status = LoadFile2->LoadFile (\r
-                             LoadFile2,\r
-                             DevicePathNode,\r
-                             FALSE,\r
-                             &ImageBufferSize,\r
-                             ImageBuffer\r
-                             );\r
+        Status          = LoadFile2->LoadFile (\r
+                                       LoadFile2,\r
+                                       DevicePathNode,\r
+                                       FALSE,\r
+                                       &ImageBufferSize,\r
+                                       ImageBuffer\r
+                                       );\r
         if (Status == EFI_BUFFER_TOO_SMALL) {\r
           ImageBuffer = AllocatePool (ImageBufferSize);\r
           if (ImageBuffer == NULL) {\r
             Status = EFI_OUT_OF_RESOURCES;\r
           } else {\r
             Status = LoadFile2->LoadFile (\r
-                                 LoadFile2,\r
-                                 DevicePathNode,\r
-                                 FALSE,\r
-                                 &ImageBufferSize,\r
-                                 ImageBuffer\r
-                                 );\r
+                                  LoadFile2,\r
+                                  DevicePathNode,\r
+                                  FALSE,\r
+                                  &ImageBufferSize,\r
+                                  ImageBuffer\r
+                                  );\r
           }\r
         }\r
       }\r
+\r
       if (!EFI_ERROR (Status)) {\r
         goto Finish;\r
       }\r
@@ -889,22 +892,22 @@ GetFileBufferByFilePath (
   // Attempt to access the file via LoadFile interface\r
   //\r
   DevicePathNode = OrigDevicePathNode;\r
-  Status = gBS->LocateDevicePath (&gEfiLoadFileProtocolGuid, &DevicePathNode, &Handle);\r
+  Status         = gBS->LocateDevicePath (&gEfiLoadFileProtocolGuid, &DevicePathNode, &Handle);\r
   if (!EFI_ERROR (Status)) {\r
-    Status = gBS->HandleProtocol (Handle, &gEfiLoadFileProtocolGuid, (VOID**)&LoadFile);\r
+    Status = gBS->HandleProtocol (Handle, &gEfiLoadFileProtocolGuid, (VOID **)&LoadFile);\r
     if (!EFI_ERROR (Status)) {\r
       //\r
       // Call LoadFile with the correct buffer size\r
       //\r
       ImageBufferSize = 0;\r
       ImageBuffer     = NULL;\r
-      Status = LoadFile->LoadFile (\r
-                           LoadFile,\r
-                           DevicePathNode,\r
-                           BootPolicy,\r
-                           &ImageBufferSize,\r
-                           ImageBuffer\r
-                           );\r
+      Status          = LoadFile->LoadFile (\r
+                                    LoadFile,\r
+                                    DevicePathNode,\r
+                                    BootPolicy,\r
+                                    &ImageBufferSize,\r
+                                    ImageBuffer\r
+                                    );\r
       if (Status == EFI_BUFFER_TOO_SMALL) {\r
         ImageBuffer = AllocatePool (ImageBufferSize);\r
         if (ImageBuffer == NULL) {\r
@@ -929,6 +932,7 @@ Finish:
       FreePool (ImageBuffer);\r
       ImageBuffer = NULL;\r
     }\r
+\r
     *FileSize = 0;\r
   } else {\r
     *FileSize = ImageBufferSize;\r
@@ -981,15 +985,15 @@ GetFileDevicePathFromAnyFv (
   OUT       EFI_DEVICE_PATH_PROTOCOL  **FvFileDevicePath\r
   )\r
 {\r
-  EFI_STATUS                        Status;\r
-  EFI_HANDLE                        *HandleBuffer;\r
-  UINTN                             HandleCount;\r
-  UINTN                             Index;\r
-  EFI_HANDLE                        FvHandle;\r
-  EFI_DEVICE_PATH_PROTOCOL          *FvDevicePath;\r
-  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *TempFvFileDevicePath;\r
-  VOID                              *Buffer;\r
-  UINTN                             Size;\r
+  EFI_STATUS                         Status;\r
+  EFI_HANDLE                         *HandleBuffer;\r
+  UINTN                              HandleCount;\r
+  UINTN                              Index;\r
+  EFI_HANDLE                         FvHandle;\r
+  EFI_DEVICE_PATH_PROTOCOL           *FvDevicePath;\r
+  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  *TempFvFileDevicePath;\r
+  VOID                               *Buffer;\r
+  UINTN                              Size;\r
 \r
   if (FvFileDevicePath == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -1008,14 +1012,14 @@ GetFileDevicePathFromAnyFv (
   // will locate the FFS faster.\r
   //\r
   FvHandle = InternalImageHandleToFvHandle (gImageHandle);\r
-  Status = InternalGetSectionFromFv (\r
-             FvHandle,\r
-             NameGuid,\r
-             SectionType,\r
-             SectionInstance,\r
-             &Buffer,\r
-             &Size\r
-             );\r
+  Status   = InternalGetSectionFromFv (\r
+               FvHandle,\r
+               NameGuid,\r
+               SectionType,\r
+               SectionInstance,\r
+               &Buffer,\r
+               &Size\r
+               );\r
   if (!EFI_ERROR (Status)) {\r
     goto Done;\r
   }\r
@@ -1073,7 +1077,8 @@ Done:
         *FvFileDevicePath = NULL;\r
         return EFI_OUT_OF_RESOURCES;\r
       }\r
-      EfiInitializeFwVolDevicepathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH*)TempFvFileDevicePath, NameGuid);\r
+\r
+      EfiInitializeFwVolDevicepathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)TempFvFileDevicePath, NameGuid);\r
       SetDevicePathEndNode (NextDevicePathNode (TempFvFileDevicePath));\r
       *FvFileDevicePath = AppendDevicePath (\r
                             FvDevicePath,\r