]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: BcfgDisplayDump(): hoist NULL-init of DevPath[String]
authorLaszlo Ersek <lersek@redhat.com>
Thu, 21 Jan 2016 18:40:00 +0000 (18:40 +0000)
committerlersek <lersek@Edk2>
Thu, 21 Jan 2016 18:40:00 +0000 (18:40 +0000)
It will help with error handling if we move these initializations near the
top of the loop body.

This patch is not supposed to change 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@19708 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c

index f6f4ab35ef228009eac754c87b6a01be48f164c6..f5ae7bc0d9de6fdd7d9cfada2a6215d704323b07 100644 (file)
@@ -1060,6 +1060,9 @@ BcfgDisplayDump(
   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
 \r
     Status = gRT->GetVariable(\r
@@ -1085,15 +1088,10 @@ BcfgDisplayDump(
 \r
     if ((*(UINT16*)(Buffer+4)) != 0) {\r
       DevPath = AllocateZeroPool(*(UINT16*)(Buffer+4));\r
-      if (DevPath == NULL) {\r
-        DevPathString = NULL;\r
-      } else {\r
+      if (DevPath != NULL) {\r
         CopyMem(DevPath, Buffer+6+StrSize((CHAR16*)(Buffer+6)), *(UINT16*)(Buffer+4));\r
         DevPathString = ConvertDevicePathToText(DevPath, TRUE, FALSE);\r
       }\r
-    } else {\r
-      DevPath       = NULL;\r
-      DevPathString = NULL;\r
     }\r
     ShellPrintHiiEx(\r
       -1,\r