]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/PiSmmCpuDxeSmm: improve the coding style
authorEric Dong <eric.dong@intel.com>
Tue, 7 Jan 2020 00:48:17 +0000 (08:48 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 8 Jan 2020 00:32:15 +0000 (00:32 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2434

Current code use below loops to enumerate the CPUs:
  for (Index = mMaxNumberOfCpus; Index-- > 0;) {
it has no issue but not easy for the developers to read the code.

Update above code to below style,
  for (Index = 0; Index < mMaxNumberOfCpus; Index++) {
It make the developers easy to read and consistent with other
similar cases in this driver.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Eric Dong <eric.dong@intel.com>
UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c

index f445d7b0300bce9ed9f1c8c8e21f041f87559df2..35a6996ba345792f1de96481367aa33b55d523d6 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 SMM MP service implementation\r
 \r
-Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.<BR>\r
 Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>\r
 \r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
@@ -137,7 +137,7 @@ ReleaseAllAPs (
 {\r
   UINTN                             Index;\r
 \r
-  for (Index = mMaxNumberOfCpus; Index-- > 0;) {\r
+  for (Index = 0; Index < mMaxNumberOfCpus; Index++) {\r
     if (IsPresentAp (Index)) {\r
       ReleaseSemaphore (mSmmMpSyncData->CpuData[Index].Run);\r
     }\r
@@ -170,7 +170,7 @@ AllCpusInSmmWithExceptions (
 \r
   CpuData = mSmmMpSyncData->CpuData;\r
   ProcessorInfo = gSmmCpuPrivate->ProcessorInfo;\r
-  for (Index = mMaxNumberOfCpus; Index-- > 0;) {\r
+  for (Index = 0; Index < mMaxNumberOfCpus; Index++) {\r
     if (!(*(CpuData[Index].Present)) && ProcessorInfo[Index].ProcessorId != INVALID_APIC_ID) {\r
       if (((Exceptions & ARRIVAL_EXCEPTION_DELAYED) != 0) && SmmCpuFeaturesGetSmmRegister (Index, SmmRegSmmDelayed) != 0) {\r
         continue;\r
@@ -305,7 +305,7 @@ SmmWaitForApArrival (
     //\r
     // Send SMI IPIs to bring outside processors in\r
     //\r
-    for (Index = mMaxNumberOfCpus; Index-- > 0;) {\r
+    for (Index = 0; Index < mMaxNumberOfCpus; Index++) {\r
       if (!(*(mSmmMpSyncData->CpuData[Index].Present)) && gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId != INVALID_APIC_ID) {\r
         SendSmiIpi ((UINT32)gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId);\r
       }\r
@@ -361,7 +361,7 @@ WaitForAllAPsNotBusy (
 {\r
   UINTN                             Index;\r
 \r
-  for (Index = mMaxNumberOfCpus; Index-- > 0;) {\r
+  for (Index = 0; Index < mMaxNumberOfCpus; Index++) {\r
     //\r
     // Ignore BSP and APs which not call in SMM.\r
     //\r
@@ -608,7 +608,7 @@ BSPHandler (
     //\r
     while (TRUE) {\r
       PresentCount = 0;\r
-      for (Index = mMaxNumberOfCpus; Index-- > 0;) {\r
+      for (Index = 0; Index < mMaxNumberOfCpus; Index++) {\r
         if (*(mSmmMpSyncData->CpuData[Index].Present)) {\r
           PresentCount ++;\r
         }\r
@@ -1343,7 +1343,7 @@ InternalSmmStartupAllAPs (
   }\r
 \r
   CpuCount = 0;\r
-  for (Index = mMaxNumberOfCpus; Index-- > 0;) {\r
+  for (Index = 0; Index < mMaxNumberOfCpus; Index++) {\r
     if (IsPresentAp (Index)) {\r
       CpuCount ++;\r
 \r
@@ -1375,13 +1375,13 @@ InternalSmmStartupAllAPs (
   // Here code always use AcquireSpinLock instead of AcquireSpinLockOrFail for not\r
   // block mode.\r
   //\r
-  for (Index = mMaxNumberOfCpus; Index-- > 0;) {\r
+  for (Index = 0; Index < mMaxNumberOfCpus; Index++) {\r
     if (IsPresentAp (Index)) {\r
       AcquireSpinLock (mSmmMpSyncData->CpuData[Index].Busy);\r
     }\r
   }\r
 \r
-  for (Index = mMaxNumberOfCpus; Index-- > 0;) {\r
+  for (Index = 0; Index < mMaxNumberOfCpus; Index++) {\r
     if (IsPresentAp (Index)) {\r
       mSmmMpSyncData->CpuData[Index].Procedure = (EFI_AP_PROCEDURE2) Procedure;\r
       mSmmMpSyncData->CpuData[Index].Parameter = ProcedureArguments;\r