[edk2] [PATCH] MdeModulePkg/PlatVarCleanupLib: Add lib destructor for unclosed event

Hao Wu posted 1 patch 7 years, 1 month ago
Failed in applying to current master (apply log)
MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c       | 33 ++++++++++++++++++--
MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.inf |  3 +-
2 files changed, 32 insertions(+), 4 deletions(-)
[edk2] [PATCH] MdeModulePkg/PlatVarCleanupLib: Add lib destructor for unclosed event
Posted by Hao Wu 7 years, 1 month ago
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
 MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c       | 33 ++++++++++++++++++--
 MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.inf |  3 +-
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c
index b96f8ddd83..c5fd30e219 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 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2015 - 2017, 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
@@ -22,6 +22,8 @@ EDKII_VAR_CHECK_PROTOCOL    *mVarCheck = NULL;
 ///
 BOOLEAN                     mEndOfDxe = FALSE;
 
+EFI_EVENT                   mPlatVarCleanupLibEndOfDxeEvent = NULL;
+
 LIST_ENTRY                  mUserVariableList = INITIALIZE_LIST_HEAD_VARIABLE (mUserVariableList);
 UINT16                      mUserVariableCount = 0;
 UINT16                      mMarkedUserVariableCount = 0;
@@ -1229,7 +1231,6 @@ PlatformVarCleanupLibConstructor (
   )
 {
   EFI_STATUS    Status;
-  EFI_EVENT     Event;
 
   mLastVarErrorFlag = InternalGetVarErrorFlag ();
   DEBUG ((EFI_D_INFO, "mLastVarErrorFlag - 0x%02x\n", mLastVarErrorFlag));
@@ -1243,10 +1244,36 @@ PlatformVarCleanupLibConstructor (
                   PlatformVarCleanupEndOfDxeEvent,
                   NULL,
                   &gEfiEndOfDxeEventGroupGuid,
-                  &Event
+                  &mPlatVarCleanupLibEndOfDxeEvent
                   );
   ASSERT_EFI_ERROR (Status);
 
   return EFI_SUCCESS;
 }
 
+/**
+  The destructor function closes the End of DXE event.
+
+  @param  ImageHandle   The firmware allocated handle for the EFI image.
+  @param  SystemTable   A pointer to the EFI System Table.
+
+  @retval EFI_SUCCESS   The destructor completed successfully.
+
+**/
+EFI_STATUS
+EFIAPI
+PlatformVarCleanupLibDestructor (
+  IN EFI_HANDLE         ImageHandle,
+  IN EFI_SYSTEM_TABLE   *SystemTable
+  )
+{
+  EFI_STATUS    Status;
+
+  //
+  // Close the End of DXE event.
+  //
+  Status = gBS->CloseEvent (mPlatVarCleanupLibEndOfDxeEvent);
+  ASSERT_EFI_ERROR (Status);
+
+  return EFI_SUCCESS;
+}
diff --git a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.inf b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.inf
index a3498cca50..6e7fcb6a5c 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 - 2016, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions
@@ -23,6 +23,7 @@
   VERSION_STRING                = 1.0
   LIBRARY_CLASS                 = PlatformVarCleanupLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
   CONSTRUCTOR                   = PlatformVarCleanupLibConstructor
+  DESTRUCTOR                    = PlatformVarCleanupLibDestructor
 
 #
 # The following information is for reference only and not required by the build tools.
-- 
2.12.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH] MdeModulePkg/PlatVarCleanupLib: Add lib destructor for unclosed event
Posted by Zeng, Star 7 years, 1 month ago
Reviewed-by: Star Zeng <star.zeng@intel.com>

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Hao Wu
Sent: Friday, March 10, 2017 2:15 PM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A <hao.a.wu@intel.com>; Zeng, Star <star.zeng@intel.com>
Subject: [edk2] [PATCH] MdeModulePkg/PlatVarCleanupLib: Add lib destructor for unclosed event

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
 MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c       | 33 ++++++++++++++++++--
 MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.inf |  3 +-
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c
index b96f8ddd83..c5fd30e219 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 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2015 - 2017, 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
@@ -22,6 +22,8 @@ EDKII_VAR_CHECK_PROTOCOL    *mVarCheck = NULL;
 ///
 BOOLEAN                     mEndOfDxe = FALSE;
 
+EFI_EVENT                   mPlatVarCleanupLibEndOfDxeEvent = NULL;
+
 LIST_ENTRY                  mUserVariableList = INITIALIZE_LIST_HEAD_VARIABLE (mUserVariableList);
 UINT16                      mUserVariableCount = 0;
 UINT16                      mMarkedUserVariableCount = 0;
@@ -1229,7 +1231,6 @@ PlatformVarCleanupLibConstructor (
   )
 {
   EFI_STATUS    Status;
-  EFI_EVENT     Event;
 
   mLastVarErrorFlag = InternalGetVarErrorFlag ();
   DEBUG ((EFI_D_INFO, "mLastVarErrorFlag - 0x%02x\n", mLastVarErrorFlag)); @@ -1243,10 +1244,36 @@ PlatformVarCleanupLibConstructor (
                   PlatformVarCleanupEndOfDxeEvent,
                   NULL,
                   &gEfiEndOfDxeEventGroupGuid,
-                  &Event
+                  &mPlatVarCleanupLibEndOfDxeEvent
                   );
   ASSERT_EFI_ERROR (Status);
 
   return EFI_SUCCESS;
 }
 
+/**
+  The destructor function closes the End of DXE event.
+
+  @param  ImageHandle   The firmware allocated handle for the EFI image.
+  @param  SystemTable   A pointer to the EFI System Table.
+
+  @retval EFI_SUCCESS   The destructor completed successfully.
+
+**/
+EFI_STATUS
+EFIAPI
+PlatformVarCleanupLibDestructor (
+  IN EFI_HANDLE         ImageHandle,
+  IN EFI_SYSTEM_TABLE   *SystemTable
+  )
+{
+  EFI_STATUS    Status;
+
+  //
+  // Close the End of DXE event.
+  //
+  Status = gBS->CloseEvent (mPlatVarCleanupLibEndOfDxeEvent);
+  ASSERT_EFI_ERROR (Status);
+
+  return EFI_SUCCESS;
+}
diff --git a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.inf b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.inf
index a3498cca50..6e7fcb6a5c 100644
--- a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.inf
+++ b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.i
+++ nf
@@ -1,7 +1,7 @@
 ## @file
 #  Sample platform variable cleanup library instance.
 #
-#  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2015 - 2017, Intel Corporation. All rights 
+reserved.<BR>
 #
 #  This program and the accompanying materials  #  are licensed and made available under the terms and conditions @@ -23,6 +23,7 @@
   VERSION_STRING                = 1.0
   LIBRARY_CLASS                 = PlatformVarCleanupLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
   CONSTRUCTOR                   = PlatformVarCleanupLibConstructor
+  DESTRUCTOR                    = PlatformVarCleanupLibDestructor
 
 #
 # The following information is for reference only and not required by the build tools.
--
2.12.0.windows.1

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