Re: [edk2-devel] [PATCH v3 6/6] UefiCpuPkg/MpInitLib: return early in GetBspNumber()

2024-02-26 Thread Laszlo Ersek
On 2/22/24 17:01, Gerd Hoffmann wrote:
> After finding the BSP Number return the result instead of
> continuing to loop over the remaining processors.
> 
> Suggested-by: Laszlo Ersek 
> Signed-off-by: Gerd Hoffmann 
> ---
>  UefiCpuPkg/Library/MpInitLib/MpLib.c | 11 ---
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c 
> b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> index 4b6d6d02b027..2051554207dc 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 (FALSE);
> +  return 0;
>  }
>  
>  /**

There's a somewhat sneaky change in here: if we fail to find the BSP,
then (beyond tripping an assert like before) we now return 0, rather
than MAX_UINT32.

However, that's arguably more sensible, even.

Reviewed-by: Laszlo Ersek 

Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115965): https://edk2.groups.io/g/devel/message/115965
Mute This Topic: https://groups.io/mt/104510913/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v3 6/6] UefiCpuPkg/MpInitLib: return early in GetBspNumber()

2024-02-26 Thread Laszlo Ersek
On 2/23/24 03:33, Ni, Ray wrote:
>> +  ASSERT (FALSE);
> 
> How about ASSERT (EFI_NOT_FOUND)? Which is more meaningful than FALSE.

I'll edit the patch -- assuming you mean

  ASSERT_EFI_ERROR (EFI_NOT_FOUND);

Laszlo

> 
> No matter you change or not, Reviewed-by: Ray Ni 
> 
>> +  return 0;
>>  }
>>
>>  /**
>> --
>> 2.43.2
> 
> 
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115964): https://edk2.groups.io/g/devel/message/115964
Mute This Topic: https://groups.io/mt/104510913/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v3 6/6] UefiCpuPkg/MpInitLib: return early in GetBspNumber()

2024-02-22 Thread Ni, Ray
> +  ASSERT (FALSE);

How about ASSERT (EFI_NOT_FOUND)? Which is more meaningful than FALSE.

No matter you change or not, Reviewed-by: Ray Ni 

> +  return 0;
>  }
> 
>  /**
> --
> 2.43.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115864): https://edk2.groups.io/g/devel/message/115864
Mute This Topic: https://groups.io/mt/104510913/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v3 6/6] UefiCpuPkg/MpInitLib: return early in GetBspNumber()

2024-02-22 Thread Gerd Hoffmann
After finding the BSP Number return the result instead of
continuing to loop over the remaining processors.

Suggested-by: Laszlo Ersek 
Signed-off-by: Gerd Hoffmann 
---
 UefiCpuPkg/Library/MpInitLib/MpLib.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c 
b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 4b6d6d02b027..2051554207dc 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 (FALSE);
+  return 0;
 }
 
 /**
-- 
2.43.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115831): https://edk2.groups.io/g/devel/message/115831
Mute This Topic: https://groups.io/mt/104510913/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-