Message ID | 20240730111132.1097315-2-sughosh.ganu@linaro.org |
---|---|
State | Accepted |
Commit | 22f893047db9560400415316256959ed29167d04 |
Headers | show |
Series | [1/5] linux: list: add a function to count list nodes | expand |
On Tue, 30 Jul 2024 at 05:11, Sughosh Ganu <sughosh.ganu@linaro.org> wrote: > > Use the API function list_count_nodes() to count the number of EFI > memory map entries. > > Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> > --- > lib/efi_loader/efi_memory.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) Reviewed-by: Simon Glass <sjg@chromium.org>
On 7/30/24 13:11, Sughosh Ganu wrote: > Use the API function list_count_nodes() to count the number of EFI > memory map entries. > > Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> > --- > lib/efi_loader/efi_memory.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c > index 12cf23fa3f..bfadd6bd41 100644 > --- a/lib/efi_loader/efi_memory.c > +++ b/lib/efi_loader/efi_memory.c > @@ -742,8 +742,8 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size, > efi_uintn_t *descriptor_size, > uint32_t *descriptor_version) > { > + int map_entries; This variable should be of type efi_uintn_t or size_t. Best regards Heinrich > efi_uintn_t map_size = 0; > - int map_entries = 0; > struct list_head *lhandle; > efi_uintn_t provided_map_size; > > @@ -752,8 +752,7 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size, > > provided_map_size = *memory_map_size; > > - list_for_each(lhandle, &efi_mem) > - map_entries++; > + map_entries = list_count_nodes(&efi_mem); > > map_size = map_entries * sizeof(struct efi_mem_desc); >
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 12cf23fa3f..bfadd6bd41 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -742,8 +742,8 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size, efi_uintn_t *descriptor_size, uint32_t *descriptor_version) { + int map_entries; efi_uintn_t map_size = 0; - int map_entries = 0; struct list_head *lhandle; efi_uintn_t provided_map_size; @@ -752,8 +752,7 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size, provided_map_size = *memory_map_size; - list_for_each(lhandle, &efi_mem) - map_entries++; + map_entries = list_count_nodes(&efi_mem); map_size = map_entries * sizeof(struct efi_mem_desc);
Use the API function list_count_nodes() to count the number of EFI memory map entries. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> --- lib/efi_loader/efi_memory.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)