From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from g4t3428.houston.hpe.com (g4t3428.houston.hpe.com [15.241.140.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CB3F01A1E31 for ; Wed, 5 Oct 2016 13:58:16 -0700 (PDT) Received: from SHAHTA6.americas.hpqcorp.net (unknown [16.100.127.81]) by g4t3428.houston.hpe.com (Postfix) with ESMTP id 1733270; Wed, 5 Oct 2016 20:58:15 +0000 (UTC) From: Tapan Shah To: edk2-devel@lists.01.org Cc: jaben.carsey@intel.com, Tapan Shah Date: Wed, 5 Oct 2016 15:58:05 -0500 Message-Id: <1475701085-11860-1-git-send-email-tapandshah@hpe.com> X-Mailer: git-send-email 1.9.5.msysgit.0 Subject: [PATCH] ShellPkg: Move UnicodeCollation2 Protcol locate out of UefiShellLib constructor X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Oct 2016 20:58:17 -0000 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 --- ShellPkg/Library/UefiShellLib/UefiShellLib.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index e47d535..53f54e1 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -292,18 +292,12 @@ ShellLibConstructor ( IN EFI_SYSTEM_TABLE *SystemTable ) { - EFI_STATUS Status; - mEfiShellEnvironment2 = NULL; gEfiShellProtocol = NULL; gEfiShellParametersProtocol = NULL; mEfiShellInterface = NULL; mEfiShellEnvironment2Handle = NULL; - - if (mUnicodeCollationProtocol == NULL) { - Status = gBS->LocateProtocol (&gEfiUnicodeCollation2ProtocolGuid, NULL, (VOID**)&mUnicodeCollationProtocol); - ASSERT_EFI_ERROR (Status); - } + mUnicodeCollationProtocol = NULL; // // verify that auto initialize is not set false @@ -730,6 +724,14 @@ ShellOpenFileByName( FileHandle, OpenMode); + if (mUnicodeCollationProtocol == NULL) { + Status = gBS->LocateProtocol (&gEfiUnicodeCollation2ProtocolGuid, NULL, (VOID**)&mUnicodeCollationProtocol); + if (EFI_ERROR (Status)) { + gEfiShellProtocol->CloseFile (*FileHandle); + return Status; + } + } + if ((mUnicodeCollationProtocol->StriColl (mUnicodeCollationProtocol, (CHAR16*)FileName, L"NUL") != 0) && (mUnicodeCollationProtocol->StriColl (mUnicodeCollationProtocol, (CHAR16*)FileName, L"NULL") != 0) && !EFI_ERROR(Status) && ((OpenMode & EFI_FILE_MODE_CREATE) != 0)){ -- 1.9.5.msysgit.0