Do not locate VarCheck protocol in Constructor, then the gEdkiiVarCheckProtocolGuid could be removed from [Depex]. It will be more flexible for the library Consumer to work without VarCheck protocol installed, for example at recovery boot mode with EmuRuntimeDxe.
The unused UefiLib is also been removed from [LibraryClasses] in *.inf. Cc: Ruiyu Ni <[email protected]> Cc: Feng Tian <[email protected]> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <[email protected]> --- .../Library/PlatformVarCleanupLib/PlatVarCleanupLib.c | 18 ++++++++++-------- .../PlatformVarCleanupLib/PlatformVarCleanupLib.inf | 4 +--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c index d99174c4b962..74655c6dadd2 100644 --- a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c +++ b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c @@ -1,7 +1,7 @@ /** @file Sample platform variable cleanup library implementation. -Copyright (c) 2015, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -100,6 +100,15 @@ IsUserVariable ( EFI_STATUS Status; VAR_CHECK_VARIABLE_PROPERTY Property; + if (mVarCheck == NULL) { + gBS->LocateProtocol ( + &gEdkiiVarCheckProtocolGuid, + NULL, + (VOID **) &mVarCheck + ); + } + ASSERT (mVarCheck != NULL); + ZeroMem (&Property, sizeof (Property)); Status = mVarCheck->VariablePropertyGet ( Name, @@ -1225,13 +1234,6 @@ PlatformVarCleanupLibConstructor ( mLastVarErrorFlag = InternalGetVarErrorFlag (); DEBUG ((EFI_D_INFO, "mLastVarErrorFlag - 0x%02x\n", mLastVarErrorFlag)); - Status = gBS->LocateProtocol ( - &gEdkiiVarCheckProtocolGuid, - NULL, - (VOID **) &mVarCheck - ); - ASSERT_EFI_ERROR (Status); - // // Register EFI_END_OF_DXE_EVENT_GROUP_GUID event. // diff --git a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.inf b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.inf index c56a17584a9f..a3498cca5073 100644 --- a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.inf +++ b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.inf @@ -1,7 +1,7 @@ ## @file # Sample platform variable cleanup library instance. # -# Copyright (c) 2015, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR> # # This program and the accompanying materials # are licensed and made available under the terms and conditions @@ -44,7 +44,6 @@ [Packages] [LibraryClasses] UefiBootServicesTableLib UefiRuntimeServicesTableLib - UefiLib BaseLib DebugLib BaseMemoryLib @@ -68,6 +67,5 @@ [Protocols] gEfiHiiConfigRoutingProtocolGuid ## SOMETIMES_CONSUMES [Depex] - gEdkiiVarCheckProtocolGuid AND gEfiVariableArchProtocolGuid -- 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

