]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFrameworkModulePkg/LegacyBootMaintUiLib: Refine the code
authorDandan Bi <dandan.bi@intel.com>
Wed, 9 Mar 2016 03:11:52 +0000 (11:11 +0800)
committerFeng Tian <feng.tian@intel.com>
Wed, 16 Mar 2016 02:42:03 +0000 (10:42 +0800)
Remove the ASSERT code that may be triggered in LegacyBootMaintUiLib.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUi.c

index 65d617cf38c22fc4f2eceeac1e24af0f69f81ae6..c9d6ee4d1ba62710cc7f3224b91ff6eebae25057 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Legacy Boot Maintainence UI implementation.\r
 \r
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2016, 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
@@ -109,8 +109,11 @@ HII_VENDOR_DEVICE_PATH  mLegacyBootOptionHiiVendorDevicePath = {
   @param EnBootOptionCount  Count of the enabled Boot Option Numbers\r
   @param DisBootOption      Callee allocated buffer containing the disabled Boot Option Numbers\r
   @param DisBootOptionCount Count of the disabled Boot Option Numbers\r
+\r
+  @return EFI_SUCCESS       The function completed successfully.\r
+  @retval other             Contain some error, details see  the status return by gRT->SetVariable.\r
 **/\r
-VOID\r
+EFI_STATUS\r
 OrderLegacyBootOption4SameType (\r
   UINT16                   *DevOrder,\r
   UINTN                    DevOrderCount,\r
@@ -143,6 +146,7 @@ OrderLegacyBootOption4SameType (
   *DisBootOptionCount = 0;\r
   *EnBootOptionCount  = 0;\r
   Index               = 0;\r
+  Status              = EFI_SUCCESS;\r
 \r
   ASSERT (BbsIndexArray != NULL);\r
   ASSERT (DeviceTypeArray != NULL);\r
@@ -207,11 +211,12 @@ OrderLegacyBootOption4SameType (
                   BootOrderSize,\r
                   BootOrder\r
                   );\r
-  ASSERT_EFI_ERROR (Status);\r
 \r
   FreePool (NewBootOption);\r
   FreePool (DeviceTypeArray);\r
   FreePool (BbsIndexArray);\r
+\r
+  return Status;\r
 }\r
 \r
 /**\r
@@ -222,8 +227,9 @@ OrderLegacyBootOption4SameType (
   @param NVMapData   The data for egacy BBS boot.\r
 \r
   @return EFI_SUCCESS           The function completed successfully.\r
-  @retval EFI_NOT_FOUND         If L"LegacyDevOrder" and gEfiLegacyDevOrderVariableGuid EFI Variable can be found.\r
+  @retval EFI_NOT_FOUND         If L"LegacyDevOrder" and gEfiLegacyDevOrderVariableGuid EFI Variable can not be found.\r
   @retval EFI_OUT_OF_RESOURCES  Fail to allocate memory resource\r
+  @retval other                 Contain some error, details see  the status return by gRT->SetVariable.\r
 **/\r
 EFI_STATUS\r
 UpdateBBSOption (\r
@@ -260,6 +266,8 @@ UpdateBBSOption (
   DisMap              = NULL;\r
   NewOrder            = NULL;\r
   CurrentType         = 0;\r
+  EnBootOption        = NULL;\r
+  DisBootOption       = NULL;\r
 \r
   \r
   DisMap  = mLegacyBootOptionPrivate->MaintainMapData->DisableMap;\r
@@ -381,7 +389,7 @@ UpdateBBSOption (
     //\r
     ASSERT (OptionMenu->MenuNumber == DevOrder->Length / sizeof (UINT16) - 1);\r
 \r
-    OrderLegacyBootOption4SameType (\r
+    Status = OrderLegacyBootOption4SameType (\r
       DevOrder->Data,\r
       DevOrder->Length / sizeof (UINT16) - 1,\r
       &EnBootOption,\r
@@ -389,6 +397,9 @@ UpdateBBSOption (
       &DisBootOption,\r
       &DisBootOptionCount\r
       );\r
+     if (EFI_ERROR(Status)) {\r
+       goto Fail;\r
+     }\r
 \r
     //\r
     // 2. Deactivate the DisBootOption and activate the EnBootOption\r
@@ -446,6 +457,15 @@ UpdateBBSOption (
                   OriginalPtr\r
                   );\r
 \r
+Fail:\r
+  if (EnBootOption != NULL) {\r
+    FreePool (EnBootOption);\r
+  }\r
+\r
+  if (DisBootOption != NULL) {\r
+    FreePool (DisBootOption);\r
+  }\r
+\r
   FreePool (OriginalPtr);\r
   return Status;\r
 }\r