]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c
IntelFrameworkModulePkg: Clean up source files
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / BootMaint / BBSsupport.c
index adf84f42f78e1d35d1696a2d44e91f418b5a5c92..f9ba0a7bc78320037caa010e3490249085f77ed2 100644 (file)
@@ -3,7 +3,7 @@
   and manage the legacy boot option, all legacy boot option is getting from\r
   the legacy BBS table.\r
 \r
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<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
@@ -53,9 +53,9 @@ OrderLegacyBootOption4SameType (
   UINTN                    BootOrderSize;\r
   UINTN                    Index;\r
   UINTN                    StartPosition;\r
-  \r
+\r
   BDS_COMMON_OPTION        *BootOption;\r
-  \r
+\r
   CHAR16                   OptionName[sizeof ("Boot####")];\r
   UINT16                   *BbsIndexArray;\r
   UINT16                   *DeviceTypeArray;\r
@@ -82,12 +82,12 @@ OrderLegacyBootOption4SameType (
   ASSERT (*DisBootOption != NULL);\r
 \r
   for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) {\r
-  \r
+\r
     UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", BootOrder[Index]);\r
     InitializeListHead (&List);\r
     BootOption = BdsLibVariableToOption (&List, OptionName);\r
     ASSERT (BootOption != NULL);\r
-    \r
+\r
     if ((DevicePathType (BootOption->DevicePath) == BBS_DEVICE_PATH) &&\r
         (DevicePathSubType (BootOption->DevicePath) == BBS_BBS_DP)) {\r
       //\r
@@ -119,7 +119,7 @@ OrderLegacyBootOption4SameType (
       if (BbsIndexArray[Index] == (DevOrder[DevOrderCount] & 0xFF)) {\r
         StartPosition = MIN (StartPosition, Index);\r
         NewBootOption[DevOrderCount] = BootOrder[Index];\r
-        \r
+\r
         if ((DevOrder[DevOrderCount] & 0xFF00) == 0xFF00) {\r
           (*DisBootOption)[*DisBootOptionCount] = BootOrder[Index];\r
           (*DisBootOptionCount)++;\r
@@ -151,12 +151,13 @@ OrderLegacyBootOption4SameType (
   FreePool (NewBootOption);\r
   FreePool (DeviceTypeArray);\r
   FreePool (BbsIndexArray);\r
+  FreePool (BootOrder);\r
 }\r
 \r
 /**\r
   Group the legacy boot options in the BootOption.\r
 \r
-  The routine assumes the boot options in the beginning that covers all the device \r
+  The routine assumes the boot options in the beginning that covers all the device\r
   types are ordered properly and re-position the following boot options just after\r
   the corresponding boot options with the same device type.\r
   For example:\r
@@ -205,7 +206,7 @@ GroupMultipleLegacyBootOption4SameType (
       //\r
       // Legacy Boot Option\r
       //\r
-      ASSERT ((((BBS_BBS_DEVICE_PATH *) BootOption->DevicePath)->DeviceType & 0xF) < sizeof (DeviceTypeIndex) / sizeof (DeviceTypeIndex[0]));\r
+      ASSERT ((((BBS_BBS_DEVICE_PATH *) BootOption->DevicePath)->DeviceType & 0xF) < ARRAY_SIZE (DeviceTypeIndex));\r
       NextIndex = &DeviceTypeIndex[((BBS_BBS_DEVICE_PATH *) BootOption->DevicePath)->DeviceType & 0xF];\r
 \r
       if (*NextIndex == (UINTN) -1) {\r
@@ -224,7 +225,7 @@ GroupMultipleLegacyBootOption4SameType (
         //\r
         // Update the DeviceTypeIndex array to reflect the right shift operation\r
         //\r
-        for (DeviceIndex = 0; DeviceIndex < sizeof (DeviceTypeIndex) / sizeof (DeviceTypeIndex[0]); DeviceIndex++) {\r
+        for (DeviceIndex = 0; DeviceIndex < ARRAY_SIZE (DeviceTypeIndex); DeviceIndex++) {\r
           if (DeviceTypeIndex[DeviceIndex] != (UINTN) -1 && DeviceTypeIndex[DeviceIndex] >= *NextIndex) {\r
             DeviceTypeIndex[DeviceIndex]++;\r
           }\r