]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeMoudlePkg/CapsulePei: Optimize AreCapsulesStaged
authorZhichao Gao <zhichao.gao@intel.com>
Mon, 10 Jun 2019 01:43:59 +0000 (09:43 +0800)
committerHao A Wu <hao.a.wu@intel.com>
Mon, 24 Jun 2019 01:18:32 +0000 (09:18 +0800)
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>
MdeModulePkg/Universal/CapsulePei/UefiCapsule.c

index b224e200fe182032d6e031613d953f6f8ffca2c9..ce6d95a7866e4b52f375c277be54cce8502f0928 100644 (file)
@@ -793,29 +793,21 @@ BuildMemoryResourceDescriptor (
 /**\r
   Check if the capsules are staged.\r
 \r
-  @param UpdateCapsules   A pointer to return the check result.\r
-\r
-  @retval EFI_INVALID_PARAMETER   The parameter is null.\r
-  @retval EFI_SUCCESS             The Capsules are staged.\r
+  @retval TRUE              The capsules are staged.\r
+  @retval FALSE             The capsules are not staged.\r
 \r
 **/\r
-EFI_STATUS\r
+BOOLEAN\r
 AreCapsulesStaged (\r
-  OUT BOOLEAN     *UpdateCapsules\r
+  VOID\r
   )\r
 {\r
   EFI_STATUS                        Status;\r
   UINTN                             Size;\r
   EFI_PEI_READ_ONLY_VARIABLE2_PPI   *PPIVariableServices;\r
-  EFI_PHYSICAL_ADDRESS              CapsuleDataPtr64 = 0;\r
-\r
-  if (UpdateCapsules == NULL) {\r
-    DEBUG ((DEBUG_ERROR, "%a Invalid parameters.  Inputs can't be NULL\n", __FUNCTION__));\r
-    ASSERT (UpdateCapsules != NULL);\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
+  EFI_PHYSICAL_ADDRESS              CapsuleDataPtr64;\r
 \r
-  *UpdateCapsules = FALSE;\r
+  CapsuleDataPtr64 = 0;\r
 \r
   Status = PeiServicesLocatePpi(\r
               &gEfiPeiReadOnlyVariable2PpiGuid,\r
@@ -826,7 +818,7 @@ AreCapsulesStaged (
 \r
   if (EFI_ERROR (Status)) {\r
     DEBUG ((DEBUG_ERROR, "Failed to find ReadOnlyVariable2PPI\n"));\r
-    return Status;\r
+    return FALSE;\r
   }\r
 \r
   //\r
@@ -843,10 +835,10 @@ AreCapsulesStaged (
                                   );\r
 \r
   if (!EFI_ERROR (Status)) {\r
-    *UpdateCapsules = TRUE;\r
+    return TRUE;\r
   }\r
 \r
-  return EFI_SUCCESS;\r
+  return FALSE;\r
 }\r
 \r
 #define MAX_SG_LIST_HEADS (20)\r
@@ -1120,19 +1112,11 @@ CheckCapsuleUpdate (
   IN EFI_PEI_SERVICES           **PeiServices\r
   )\r
 {\r
-  EFI_STATUS  Status;\r
-  BOOLEAN     Update;\r
-\r
-  Status = AreCapsulesStaged (&Update);\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    if (Update) {\r
-      Status = EFI_SUCCESS;\r
-    } else {\r
-      Status = EFI_NOT_FOUND;\r
-    }\r
+  if (AreCapsulesStaged ()) {\r
+    return EFI_SUCCESS;\r
+  } else {\r
+    return EFI_NOT_FOUND;\r
   }\r
-  return Status;\r
 }\r
 /**\r
   This function will look at a capsule and determine if it's a test pattern.\r