]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUi.c
IntelFrameworkModulePkg:Refine the code in LegacyBootMaintUiLib
[mirror_edk2.git] / IntelFrameworkModulePkg / Library / LegacyBootMaintUiLib / LegacyBootMaintUi.c
index 6a768424884aa4a18e3076d12c748d0bd0d67406..4ebba337deddc537351d8d25e61d6bf4508e0e40 100644 (file)
@@ -144,6 +144,8 @@ OrderLegacyBootOption4SameType (
   *EnBootOptionCount  = 0;\r
   Index               = 0;\r
 \r
+  ASSERT (BbsIndexArray != NULL);\r
+  ASSERT (DeviceTypeArray != NULL);\r
   ASSERT (*EnBootOption != NULL);\r
   ASSERT (*DisBootOption != NULL);\r
 \r
@@ -175,6 +177,7 @@ OrderLegacyBootOption4SameType (
   //\r
   StartPosition = BootOrderSize / sizeof (UINT16);\r
   NewBootOption = AllocatePool (DevOrderCount * sizeof (UINT16));\r
+  ASSERT (NewBootOption != NULL);\r
   while (DevOrderCount-- != 0) {\r
     for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) {\r
       if (BbsIndexArray[Index] == (DevOrder[DevOrderCount] & 0xFF)) {\r
@@ -1178,6 +1181,7 @@ GetLegacyOptionsOrder (
   UINTN                       Pos;\r
   UINTN                       Bit;\r
   UINT8                       *DisMap;\r
+  UINTN                       TotalLength;\r
 \r
   LegacyDev = NULL;\r
   OptionMenu = NULL;\r
@@ -1228,9 +1232,10 @@ GetLegacyOptionsOrder (
       //\r
       // Create oneof tag here for FD/HD/CD #1 #2\r
       //\r
-      for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {  \r
-        VarDevOrder = *(UINT16 *) ((UINT8 *) DevOrder + sizeof (BBS_TYPE) + sizeof (UINT16) + Index * sizeof (UINT16));\r
-      \r
+      for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {\r
+        TotalLength = sizeof (BBS_TYPE) + sizeof (UINT16) + Index * sizeof (UINT16);\r
+        VarDevOrder = *(UINT16 *) ((UINT8 *) DevOrder + TotalLength);\r
+\r
         if (0xFF00 == (VarDevOrder & 0xFF00)) {\r
           LegacyDev[Index]  = 0xFF;\r
           Pos               = (VarDevOrder & 0xFF) / 8;\r
@@ -1241,7 +1246,7 @@ GetLegacyOptionsOrder (
         }\r
       }\r
 \r
-      VarData += sizeof (BBS_TYPE);\r
+      VarData ++;\r
       VarData += *(UINT16 *) VarData;\r
       DevOrder = (LEGACY_DEV_ORDER_ENTRY *) VarData;\r
     }\r