From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: zhichao.gao@intel.com) Received: from mga01.intel.com (mga01.intel.com []) by groups.io with SMTP; Sun, 09 Jun 2019 22:20:46 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jun 2019 22:20:46 -0700 X-ExtLoop1: 1 Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga006.fm.intel.com with ESMTP; 09 Jun 2019 22:20:44 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Ray Ni , Star Zeng , Liming Gao , Sean Brogan , Michael Turner , Bret Barkelew , Leif Lindholm , Zhichao gao Subject: [PATCH v5 3/5] MdeMoudlePkg/CapsulePei: Optimize AreCapsulesStaged Date: Mon, 10 Jun 2019 13:20:34 +0800 Message-Id: <20190610052036.11924-4-zhichao.gao@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20190610052036.11924-1-zhichao.gao@intel.com> References: <20190610052036.11924-1-zhichao.gao@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1853 AreCapsulesStaged do not need to return the status, only boolean result is useful. So directly return a boolean value. Cannot initialize the variable at its definition. Cc: Jian J Wang Cc: Hao A Wu Cc: Ray Ni Cc: Star Zeng Cc: Liming Gao Cc: Sean Brogan Cc: Michael Turner Cc: Bret Barkelew Cc: Leif Lindholm Signed-off-by: Zhichao gao --- .../Universal/CapsulePei/UefiCapsule.c | 42 ++++++------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c b/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c index b224e200fe..ce6d95a786 100644 --- a/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c +++ b/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c @@ -793,29 +793,21 @@ BuildMemoryResourceDescriptor ( /** Check if the capsules are staged. - @param UpdateCapsules A pointer to return the check result. - - @retval EFI_INVALID_PARAMETER The parameter is null. - @retval EFI_SUCCESS The Capsules are staged. + @retval TRUE The capsules are staged. + @retval FALSE The capsules are not staged. **/ -EFI_STATUS +BOOLEAN AreCapsulesStaged ( - OUT BOOLEAN *UpdateCapsules + VOID ) { EFI_STATUS Status; UINTN Size; EFI_PEI_READ_ONLY_VARIABLE2_PPI *PPIVariableServices; - EFI_PHYSICAL_ADDRESS CapsuleDataPtr64 = 0; - - if (UpdateCapsules == NULL) { - DEBUG ((DEBUG_ERROR, "%a Invalid parameters. Inputs can't be NULL\n", __FUNCTION__)); - ASSERT (UpdateCapsules != NULL); - return EFI_INVALID_PARAMETER; - } + EFI_PHYSICAL_ADDRESS CapsuleDataPtr64; - *UpdateCapsules = FALSE; + CapsuleDataPtr64 = 0; Status = PeiServicesLocatePpi( &gEfiPeiReadOnlyVariable2PpiGuid, @@ -826,7 +818,7 @@ AreCapsulesStaged ( if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "Failed to find ReadOnlyVariable2PPI\n")); - return Status; + return FALSE; } // @@ -843,10 +835,10 @@ AreCapsulesStaged ( ); if (!EFI_ERROR (Status)) { - *UpdateCapsules = TRUE; + return TRUE; } - return EFI_SUCCESS; + return FALSE; } #define MAX_SG_LIST_HEADS (20) @@ -1120,19 +1112,11 @@ CheckCapsuleUpdate ( IN EFI_PEI_SERVICES **PeiServices ) { - EFI_STATUS Status; - BOOLEAN Update; - - Status = AreCapsulesStaged (&Update); - - if (!EFI_ERROR (Status)) { - if (Update) { - Status = EFI_SUCCESS; - } else { - Status = EFI_NOT_FOUND; - } + if (AreCapsulesStaged ()) { + return EFI_SUCCESS; + } else { + return EFI_NOT_FOUND; } - return Status; } /** This function will look at a capsule and determine if it's a test pattern. -- 2.21.0.windows.1