summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2024-02-22 17:01:06 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-02-26 21:56:21 +0000
commitd25421d0d8cd2493b30215ef80d2424ecb19c870 (patch)
tree04f9ad2e8126b51d10c9df2ee8ed922e62de3daf
parent5e09b5d6d7eda2c88d12ee27db18b3c75ed24dd3 (diff)
downloadedk2-d25421d0d8cd2493b30215ef80d2424ecb19c870.tar.gz
edk2-d25421d0d8cd2493b30215ef80d2424ecb19c870.tar.bz2
edk2-d25421d0d8cd2493b30215ef80d2424ecb19c870.zip
UefiCpuPkg/MpInitLib: return early in GetBspNumber()
After finding the BSP Number return the result instead of continuing to loop over the remaining processors. Suggested-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-Id: <20240222160106.686484-7-kraxel@redhat.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> [lersek@redhat.com: s/ASSERT (FALSE)/ASSERT_EFI_ERROR (EFI_NOT_FOUND)/ [Ray]]
-rw-r--r--UefiCpuPkg/Library/MpInitLib/MpLib.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 4b6d6d02b0..8c186211fb 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -1903,15 +1903,13 @@ GetBspNumber (
)
{
UINT32 ApicId;
- UINT32 BspNumber;
UINT32 Index;
CONST MP_HAND_OFF *MpHandOff;
//
// Get the processor number for the BSP
//
- BspNumber = MAX_UINT32;
- ApicId = GetInitialApicId ();
+ ApicId = GetInitialApicId ();
for (MpHandOff = FirstMpHandOff;
MpHandOff != NULL;
@@ -1919,14 +1917,13 @@ GetBspNumber (
{
for (Index = 0; Index < MpHandOff->CpuCount; Index++) {
if (MpHandOff->Info[Index].ApicId == ApicId) {
- BspNumber = MpHandOff->ProcessorIndex + Index;
+ return MpHandOff->ProcessorIndex + Index;
}
}
}
- ASSERT (BspNumber != MAX_UINT32);
-
- return BspNumber;
+ ASSERT_EFI_ERROR (EFI_NOT_FOUND);
+ return 0;
}
/**