]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Move UnicodeCollation2 Protcol locate out of UefiShellLib constructor
authorTapan Shah <tapandshah@hpe.com>
Wed, 5 Oct 2016 20:58:05 +0000 (13:58 -0700)
committerJaben Carsey <jaben.carsey@intel.com>
Wed, 5 Oct 2016 22:19:40 +0000 (15:19 -0700)
Move gEfiUnicodeCollation2ProtocolGuid protocol outside of UefiShellLib constructor
function.
Locate gEfiUnicodeCollation2ProtocolGuid protocol in ShellOpenFileByName() which
consumes this protocol API.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Tapan Shah <tapandshah@hpe.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
ShellPkg/Library/UefiShellLib/UefiShellLib.c

index e47d5350e0eea8db2b98826f1250a79389e06cbb..53f54e1746d48bb1e41f06c288477f227e1f08be 100644 (file)
@@ -292,18 +292,12 @@ ShellLibConstructor (
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
 {\r
-  EFI_STATUS  Status;\r
-\r
   mEfiShellEnvironment2       = NULL;\r
   gEfiShellProtocol           = NULL;\r
   gEfiShellParametersProtocol = NULL;\r
   mEfiShellInterface          = NULL;\r
   mEfiShellEnvironment2Handle = NULL;\r
-\r
-  if (mUnicodeCollationProtocol == NULL) {\r
-    Status = gBS->LocateProtocol (&gEfiUnicodeCollation2ProtocolGuid, NULL, (VOID**)&mUnicodeCollationProtocol);\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
+  mUnicodeCollationProtocol   = NULL;\r
 \r
   //\r
   // verify that auto initialize is not set false\r
@@ -730,6 +724,14 @@ ShellOpenFileByName(
                                                FileHandle,\r
                                                OpenMode);\r
 \r
+    if (mUnicodeCollationProtocol == NULL) {\r
+      Status = gBS->LocateProtocol (&gEfiUnicodeCollation2ProtocolGuid, NULL, (VOID**)&mUnicodeCollationProtocol);\r
+      if (EFI_ERROR (Status)) {\r
+        gEfiShellProtocol->CloseFile (*FileHandle);\r
+        return Status;\r
+      }\r
+    }\r
+\r
     if ((mUnicodeCollationProtocol->StriColl (mUnicodeCollationProtocol, (CHAR16*)FileName, L"NUL") != 0) &&\r
         (mUnicodeCollationProtocol->StriColl (mUnicodeCollationProtocol, (CHAR16*)FileName, L"NULL") != 0) &&\r
          !EFI_ERROR(Status) && ((OpenMode & EFI_FILE_MODE_CREATE) != 0)){\r