[edk2] [PATCH 2/3] ShellPkg/HandleParsingLib: Open LoadedImageProtocol first

Jeff Westfahl posted 3 patches 7 years, 6 months ago
[edk2] [PATCH 2/3] ShellPkg/HandleParsingLib: Open LoadedImageProtocol first
Posted by Jeff Westfahl 7 years, 6 months ago
This patch changes the order of operations to make sure we can open the
LoadedImageProtocol before getting the format string. This should not
affect functionality, and makes the next patch easier to review.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com>
---
 .../Library/UefiHandleParsingLib/UefiHandleParsingLib.c   | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index 2db8a3a..c96f6dd 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -177,13 +177,6 @@ LoadedImageProtocolDumpInformation(
     return (CatSPrint(NULL, L"LoadedImage"));
   }
 
-  HandleParsingHiiInit();
-
-  Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_LI_DUMP_MAIN), NULL);
-  if (Temp == NULL) {
-    return NULL;
-  }
-
   Status = gBS->OpenProtocol (
                 TheHandle,
                 &gEfiLoadedImageProtocolGuid,
@@ -194,7 +187,13 @@ LoadedImageProtocolDumpInformation(
                );
 
   if (EFI_ERROR (Status)) {
-    SHELL_FREE_NON_NULL (Temp);
+    return NULL;
+  }
+
+  HandleParsingHiiInit();
+
+  Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_LI_DUMP_MAIN), NULL);
+  if (Temp == NULL) {
     return NULL;
   }
 
-- 
2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel