[PATCH 1/1] efi_loader: use list_count_nodes() in efi_protocols_per_handle()

Simplify the code by using the list_count_nodes() function.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com --- lib/efi_loader/efi_boottime.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index eedc5f39549..4f52284b4c6 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -2509,16 +2509,12 @@ static efi_status_t EFIAPI efi_protocols_per_handle( return EFI_EXIT(EFI_INVALID_PARAMETER);
*protocol_buffer = NULL; - *protocol_buffer_count = 0;
efiobj = efi_search_obj(handle); if (!efiobj) return EFI_EXIT(EFI_INVALID_PARAMETER);
- /* Count protocols */ - list_for_each(protocol_handle, &efiobj->protocols) { - ++*protocol_buffer_count; - } + *protocol_buffer_count = list_count_nodes(&efiobj->protocols);
/* Copy GUIDs */ if (*protocol_buffer_count) {

On Wed, 31 Jul 2024 at 13:43, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
Simplify the code by using the list_count_nodes() function.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com
I have made changes to the files that you mentioned in your review, and plan to come up with a v2 once the CI goes through. Thanks.
-sughosh
lib/efi_loader/efi_boottime.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index eedc5f39549..4f52284b4c6 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -2509,16 +2509,12 @@ static efi_status_t EFIAPI efi_protocols_per_handle( return EFI_EXIT(EFI_INVALID_PARAMETER);
*protocol_buffer = NULL;
*protocol_buffer_count = 0; efiobj = efi_search_obj(handle); if (!efiobj) return EFI_EXIT(EFI_INVALID_PARAMETER);
/* Count protocols */
list_for_each(protocol_handle, &efiobj->protocols) {
++*protocol_buffer_count;
}
*protocol_buffer_count = list_count_nodes(&efiobj->protocols); /* Copy GUIDs */ if (*protocol_buffer_count) {
-- 2.45.2

On 31.07.24 10:34, Sughosh Ganu wrote:
On Wed, 31 Jul 2024 at 13:43, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
Simplify the code by using the list_count_nodes() function.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com
I have made changes to the files that you mentioned in your review, and plan to come up with a v2 once the CI goes through. Thanks.
Hello Sughosh,
Please, rebase on https://source.denx.de/u-boot/custodians/u-boot-efi/-/commits/efi-2024-10-rc... for which I will create a pull request. It contains your v1.
Best regards
Heinrich
-sughosh
lib/efi_loader/efi_boottime.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index eedc5f39549..4f52284b4c6 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -2509,16 +2509,12 @@ static efi_status_t EFIAPI efi_protocols_per_handle( return EFI_EXIT(EFI_INVALID_PARAMETER);
*protocol_buffer = NULL;
*protocol_buffer_count = 0; efiobj = efi_search_obj(handle); if (!efiobj) return EFI_EXIT(EFI_INVALID_PARAMETER);
/* Count protocols */
list_for_each(protocol_handle, &efiobj->protocols) {
++*protocol_buffer_count;
}
*protocol_buffer_count = list_count_nodes(&efiobj->protocols); /* Copy GUIDs */ if (*protocol_buffer_count) {
-- 2.45.2
participants (2)
-
Heinrich Schuchardt
-
Sughosh Ganu