summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhichao Gao <zhichao.gao@intel.com>2019-06-10 09:43:59 +0800
committerHao A Wu <hao.a.wu@intel.com>2019-06-24 09:18:32 +0800
commitf654a18b660e826b6e7df686f7a2bdc7b2264c37 (patch)
tree37463b987acb9610b7a9b7b1871d9aea34bab109
parent0c5296153828e87a02545ccd1a4055fbd56875b4 (diff)
downloadedk2-f654a18b660e826b6e7df686f7a2bdc7b2264c37.zip
edk2-f654a18b660e826b6e7df686f7a2bdc7b2264c37.tar.gz
edk2-f654a18b660e826b6e7df686f7a2bdc7b2264c37.tar.bz2
MdeMoudlePkg/CapsulePei: Optimize AreCapsulesStaged
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 <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Michael Turner <Michael.Turner@microsoft.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Leif Lindholm <leif.lindholm@linaro.org> Signed-off-by: Zhichao gao <zhichao.gao@intel.com> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
-rw-r--r--MdeModulePkg/Universal/CapsulePei/UefiCapsule.c42
1 files changed, 13 insertions, 29 deletions
diff --git a/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c b/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c
index b224e20..ce6d95a 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.