]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c
MdeModulePkg/BootMaintenanceManagerUiLib: rebase to ARRAY_SIZE()
[mirror_edk2.git] / MdeModulePkg / Library / BootMaintenanceManagerUiLib / Variable.c
index 2ecf5b660540156bb5bd589d25b24104079ee87c..746b2335edc525f318c6299c578087be29d577ae 100644 (file)
@@ -300,62 +300,6 @@ Var_ChangeDriverOrder (
   return EFI_SUCCESS;\r
 }\r
 \r
-/**\r
-  Update the device path of "ConOut", "ConIn" and "ErrOut" \r
-  based on the new BaudRate, Data Bits, parity and Stop Bits\r
-  set.\r
-\r
-**/\r
-VOID\r
-Var_UpdateAllConsoleOption (\r
-  VOID\r
-  )\r
-{\r
-  EFI_DEVICE_PATH_PROTOCOL  *OutDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *InpDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *ErrDevicePath;\r
-  EFI_STATUS                Status;\r
-\r
-  GetEfiGlobalVariable2 (L"ConOut", (VOID**)&OutDevicePath, NULL);\r
-  GetEfiGlobalVariable2 (L"ConIn", (VOID**)&InpDevicePath, NULL);\r
-  GetEfiGlobalVariable2 (L"ErrOut", (VOID**)&ErrDevicePath, NULL);\r
-  if (OutDevicePath != NULL) {\r
-    ChangeVariableDevicePath (OutDevicePath);\r
-    Status = gRT->SetVariable (\r
-                    L"ConOut",\r
-                    &gEfiGlobalVariableGuid,\r
-                    VAR_FLAG,\r
-                    GetDevicePathSize (OutDevicePath),\r
-                    OutDevicePath\r
-                    );\r
-    ASSERT (!EFI_ERROR (Status));\r
-  }\r
-\r
-  if (InpDevicePath != NULL) {\r
-    ChangeVariableDevicePath (InpDevicePath);\r
-    Status = gRT->SetVariable (\r
-                    L"ConIn",\r
-                    &gEfiGlobalVariableGuid,\r
-                    VAR_FLAG,\r
-                    GetDevicePathSize (InpDevicePath),\r
-                    InpDevicePath\r
-                    );\r
-    ASSERT (!EFI_ERROR (Status));\r
-  }\r
-\r
-  if (ErrDevicePath != NULL) {\r
-    ChangeVariableDevicePath (ErrDevicePath);\r
-    Status = gRT->SetVariable (\r
-                    L"ErrOut",\r
-                    &gEfiGlobalVariableGuid,\r
-                    VAR_FLAG,\r
-                    GetDevicePathSize (ErrDevicePath),\r
-                    ErrDevicePath\r
-                    );\r
-    ASSERT (!EFI_ERROR (Status));\r
-  }\r
-}\r
-\r
 /**\r
   This function delete and build multi-instance device path for\r
   specified type of console device.\r
@@ -427,7 +371,7 @@ Var_UpdateConsoleOption (
       Vendor.Header.Type    = MESSAGING_DEVICE_PATH;\r
       Vendor.Header.SubType = MSG_VENDOR_DP;\r
       \r
-      ASSERT (NewTerminalContext->TerminalType < (sizeof (TerminalTypeGuid) / sizeof (TerminalTypeGuid[0])));\r
+      ASSERT (NewTerminalContext->TerminalType < (ARRAY_SIZE (TerminalTypeGuid)));\r
       CopyMem (\r
         &Vendor.Guid,\r
         &TerminalTypeGuid[NewTerminalContext->TerminalType],\r
@@ -521,7 +465,9 @@ Var_UpdateErrorOutOption (
   @param OptionalData    The optional load option.\r
   @param ForceReconnect  If to force reconnect.\r
 \r
-  @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.\r
+  @retval other                Contain some errors when excuting this function.See function\r
+                               EfiBootManagerInitializeLoadOption/EfiBootManagerAddLoadOptionVariabl\r
+                               for detail return information.\r
   @retval EFI_SUCCESS          If function completes successfully.\r
 \r
 **/\r
@@ -581,8 +527,14 @@ Var_UpdateDriverOption (
              OptionalDesData,\r
              OptionalDataSize\r
            );\r
-  if (!EFI_ERROR (Status)){\r
-    Status = EfiBootManagerAddLoadOptionVariable (&LoadOption,(UINTN) -1 );\r
+  if (EFI_ERROR (Status)){\r
+    return Status;\r
+  }\r
+\r
+  Status = EfiBootManagerAddLoadOptionVariable (&LoadOption,(UINTN) -1 );\r
+  if (EFI_ERROR (Status)) {\r
+    EfiBootManagerFreeLoadOption(&LoadOption);\r
+    return Status;\r
   }\r
 \r
   NewLoadContext                  = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
@@ -638,7 +590,9 @@ Var_UpdateDriverOption (
 \r
   @param CallbackData    The BMM context data.\r
 \r
-  @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.\r
+  @retval other                Contain some errors when excuting this function. See function\r
+                               EfiBootManagerInitializeLoadOption/EfiBootManagerAddLoadOptionVariabl\r
+                               for detail return information.\r
   @retval EFI_SUCCESS          If function completes successfully.\r
 \r
 **/\r
@@ -691,8 +645,14 @@ Var_UpdateBootOption (
              OptionalData,\r
              OptionalDataSize\r
            );\r
-  if (!EFI_ERROR (Status)){\r
-    Status = EfiBootManagerAddLoadOptionVariable (&LoadOption,(UINTN) -1 );\r
+  if (EFI_ERROR (Status)){\r
+    return Status;\r
+  }\r
+\r
+  Status = EfiBootManagerAddLoadOptionVariable (&LoadOption,(UINTN) -1 );\r
+  if (EFI_ERROR (Status)) {\r
+    EfiBootManagerFreeLoadOption(&LoadOption);\r
+    return Status;\r
   }\r
 \r
   NewLoadContext                  = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r