Skip to content

Commit

Permalink
UefiCpuPkg/MpInitLib: return early in GetBspNumber()
Browse files Browse the repository at this point in the history
After finding the BSP Number return the result instead of
continuing to loop over the remaining processors.

Suggested-by: Laszlo Ersek <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
Message-Id: <[email protected]>
Reviewed-by: Ray Ni <[email protected]>
Reviewed-by: Laszlo Ersek <[email protected]>
[[email protected]: s/ASSERT (FALSE)/ASSERT_EFI_ERROR (EFI_NOT_FOUND)/ [Ray]]
  • Loading branch information
kraxel authored and mergify[bot] committed Feb 26, 2024
1 parent 5e09b5d commit d25421d
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions UefiCpuPkg/Library/MpInitLib/MpLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1903,30 +1903,27 @@ 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;
MpHandOff = GetNextMpHandOffHob (MpHandOff))
{
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;
}

/**
Expand Down

0 comments on commit d25421d

Please sign in to comment.