]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
Fix a potential bug that GetLanguages() API may return incorrect languages in a strin...
[mirror_edk2.git] / MdeModulePkg / Universal / HiiDatabaseDxe / ConfigRouting.c
index ca85619113d8648029745e494bf53afcb9fbcd33..d55fdf436671511e688f2bbbb6b8ca81d237a800 100644 (file)
@@ -1,4 +1,5 @@
 /** @file\r
+Implementation of interfaces function for EFI_HII_CONFIG_ROUTING_PROTOCOL.\r
 \r
 Copyright (c) 2007 - 2008, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
@@ -9,17 +10,6 @@ http://opensource.org/licenses/bsd-license.php
 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
 \r
-Module Name:\r
-\r
-    ConfigRouting.c\r
-\r
-Abstract:\r
-\r
-    Implementation for EFI_HII_CONFIG_ROUTING_PROTOCOL.\r
-\r
-Revision History\r
-\r
-\r
 **/\r
 \r
 \r
@@ -270,44 +260,6 @@ OutputConfigBody (
 \r
 }\r
 \r
-\r
-/**\r
-  Adjusts the size of a previously allocated buffer.\r
-\r
-\r
-  @param OldPool         A pointer to the buffer whose size is being adjusted.\r
-  @param OldSize         The size of the current buffer.\r
-  @param NewSize         The size of the new buffer.\r
-\r
-  @return The new buffer allocated.\r
-\r
-**/\r
-VOID *\r
-ReallocatePool (\r
-  IN VOID                          *OldPool,\r
-  IN UINTN                         OldSize,\r
-  IN UINTN                         NewSize\r
-  )\r
-{\r
-  VOID  *NewPool;\r
-\r
-  NewPool = NULL;\r
-  if (NewSize != 0) {\r
-    NewPool = AllocateZeroPool (NewSize);\r
-  }\r
-\r
-  if (OldPool != NULL) {\r
-    if (NewPool != NULL) {\r
-      CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);\r
-    }\r
-\r
-    gBS->FreePool (OldPool);\r
-  }\r
-\r
-  return NewPool;\r
-}\r
-\r
-\r
 /**\r
   Append a string to a multi-string format.\r
 \r
@@ -346,12 +298,12 @@ AppendToMultiString (
   if (MultiStringSize + AppendStringSize > MAX_STRING_LENGTH ||\r
       MultiStringSize > MAX_STRING_LENGTH) {\r
     *MultiString = (EFI_STRING) ReallocatePool (\r
-                                  (VOID *) (*MultiString),\r
                                   MultiStringSize,\r
-                                  MultiStringSize + AppendStringSize\r
+                                  MultiStringSize + AppendStringSize,\r
+                                  (VOID *) (*MultiString)\r
                                   );\r
+    ASSERT (*MultiString != NULL);\r
   }\r
-\r
   //\r
   // Append the incoming string\r
   //\r
@@ -500,15 +452,6 @@ HiiConfigRoutingExtractConfig (
   EFI_STRING                          AccessResults;\r
   BOOLEAN                             FirstElement;\r
 \r
-  //\r
-  // For size reduction, please define PcdSupportFullConfigRoutingProtocol \r
-  // as FALSE. But this renders the system to not 100% compliant with\r
-  // UEFI 2.1. Use this with caution.\r
-  //\r
-  if (!FeaturePcdGet (PcdSupportFullConfigRoutingProtocol)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
   if (This == NULL || Progress == NULL || Results == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -708,15 +651,6 @@ HiiConfigRoutingExportConfig (
   UINTN                               NumberConfigAccessHandles;\r
   BOOLEAN                             FirstElement;\r
 \r
-  //\r
-  // For size reduction, please define PcdSupportFullConfigRoutingProtocol \r
-  // as FALSE. But this renders the system to not 100% compliant with\r
-  // UEFI 2.1. Use this with caution.\r
-  //\r
-  if (!FeaturePcdGet (PcdSupportFullConfigRoutingProtocol)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
   if (This == NULL || Results == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -779,7 +713,7 @@ HiiConfigRoutingExportConfig (
       AccessResults = NULL;\r
     }\r
   }\r
-  gBS->FreePool (ConfigAccessHandles);\r
+  FreePool (ConfigAccessHandles);\r
 \r
   return EFI_SUCCESS;  \r
 }\r
@@ -832,15 +766,6 @@ HiiConfigRoutingRouteConfig (
   EFI_HII_CONFIG_ACCESS_PROTOCOL      *ConfigAccess;\r
   EFI_STRING                          AccessProgress;\r
 \r
-  //\r
-  // For size reduction, please define PcdSupportFullConfigRoutingProtocol \r
-  // as FALSE. But this renders the system to not 100% compliant with\r
-  // UEFI 2.1. Use this with caution.\r
-  //\r
-  if (!FeaturePcdGet (PcdSupportFullConfigRoutingProtocol)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
   if (This == NULL || Progress == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -1242,7 +1167,7 @@ Exit:
   if (Value != NULL) {\r
     FreePool (Value);\r
   }\r
-  if (ConfigElement) {\r
+  if (ConfigElement != NULL) {\r
     FreePool (ConfigElement);\r
   }\r
 \r
@@ -1369,7 +1294,7 @@ HiiConfigToBlock (
     // Get Offset\r
     //\r
     Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length);\r
-    if (Status == EFI_OUT_OF_RESOURCES) {\r
+    if (EFI_ERROR (Status)) {\r
       *Progress = ConfigResp;\r
       goto Exit;\r
     }\r
@@ -1417,7 +1342,7 @@ HiiConfigToBlock (
     // Get Value\r
     //\r
     Status = GetValueOfNumber (StringPtr, &Value, &Length);\r
-    if (Status == EFI_OUT_OF_RESOURCES) {\r
+    if (EFI_ERROR (Status)) {\r
       *Progress = ConfigResp;\r
       goto Exit;\r
     }\r
@@ -1538,15 +1463,6 @@ HiiGetAltCfg (
   BOOLEAN                             NameFlag;\r
   BOOLEAN                             PathFlag;\r
 \r
-  //\r
-  // For size reduction, please define PcdSupportFullConfigRoutingProtocol \r
-  // as FALSE. But this renders the system to not 100% compliant with\r
-  // UEFI 2.1. Use this with caution.\r
-  //\r
-  if (!FeaturePcdGet (PcdSupportFullConfigRoutingProtocol)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
   HdrStart = NULL;\r
   HdrEnd   = NULL;\r
   GuidStr  = NULL;\r
@@ -1691,7 +1607,7 @@ HiiGetAltCfg (
 \r
 Exit:\r
 \r
-  if (!EFI_ERROR (Status)) {\r
+  if (!EFI_ERROR (Status) && (Result != NULL)) {\r
     //\r
     // Copy the <ConfigHdr> and <ConfigBody>\r
     //\r