]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: BcfgDisplayDump(): eliminate FilePathList duplication
authorLaszlo Ersek <lersek@redhat.com>
Thu, 21 Jan 2016 18:40:22 +0000 (18:40 +0000)
committerlersek <lersek@Edk2>
Thu, 21 Jan 2016 18:40:22 +0000 (18:40 +0000)
Copying and releasing each EFI_LOAD_OPTION.FilePathList under the name
DevPath is wasteful -- we only need FilePathList for a single conversion
to text. Do it directly from the EFI_LOAD_OPTION object.

This patch is not supposed to change observable behavior.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ryan Harkin <ryan.harkin@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19713 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c

index aac85d3850907a86feefdd0a78ebf28cd2de8895..d109ca29a781b1ac06eaf888ff633b87f805f520 100644 (file)
@@ -1050,7 +1050,7 @@ BcfgDisplayDump(
   UINTN           LoopVar;\r
   UINTN           LoopVar2;\r
   CHAR16          *DevPathString;\r
   UINTN           LoopVar;\r
   UINTN           LoopVar2;\r
   CHAR16          *DevPathString;\r
-  VOID            *DevPath;\r
+  VOID            *FilePathList;\r
   UINTN           Errors;\r
   EFI_LOAD_OPTION *LoadOption;\r
   CHAR16          *Description;\r
   UINTN           Errors;\r
   EFI_LOAD_OPTION *LoadOption;\r
   CHAR16          *Description;\r
@@ -1066,7 +1066,6 @@ BcfgDisplayDump(
   for (LoopVar = 0 ; LoopVar < OrderCount ; LoopVar++) {\r
     Buffer        = NULL;\r
     BufferSize    = 0;\r
   for (LoopVar = 0 ; LoopVar < OrderCount ; LoopVar++) {\r
     Buffer        = NULL;\r
     BufferSize    = 0;\r
-    DevPath       = NULL;\r
     DevPathString = NULL;\r
 \r
     UnicodeSPrint(VariableName, sizeof(VariableName), L"%s%04x", Op, CurrentOrder[LoopVar]);\r
     DevPathString = NULL;\r
 \r
     UnicodeSPrint(VariableName, sizeof(VariableName), L"%s%04x", Op, CurrentOrder[LoopVar]);\r
@@ -1116,11 +1115,8 @@ BcfgDisplayDump(
     DescriptionSize = StrSize (Description);\r
 \r
     if (LoadOption->FilePathListLength != 0) {\r
     DescriptionSize = StrSize (Description);\r
 \r
     if (LoadOption->FilePathListLength != 0) {\r
-      DevPath = AllocateZeroPool(LoadOption->FilePathListLength);\r
-      if (DevPath != NULL) {\r
-        CopyMem(DevPath, Buffer+6+DescriptionSize, LoadOption->FilePathListLength);\r
-        DevPathString = ConvertDevicePathToText(DevPath, TRUE, FALSE);\r
-      }\r
+      FilePathList = (UINT8 *)Description + DescriptionSize;\r
+      DevPathString = ConvertDevicePathToText(FilePathList, TRUE, FALSE);\r
     }\r
     ShellPrintHiiEx(\r
       -1,\r
     }\r
     ShellPrintHiiEx(\r
       -1,\r
@@ -1153,9 +1149,6 @@ Cleanup:
     if (Buffer != NULL) {\r
       FreePool(Buffer);\r
     }\r
     if (Buffer != NULL) {\r
       FreePool(Buffer);\r
     }\r
-    if (DevPath != NULL) {\r
-      FreePool(DevPath);\r
-    }\r
     if (DevPathString != NULL) {\r
       FreePool(DevPathString);\r
     }\r
     if (DevPathString != NULL) {\r
       FreePool(DevPathString);\r
     }\r