MISRA C Rule 11.3 prohibits casting between pointer-to-object types that
are different types. The original code used a macro 'NextMemoryDescriptor()'
that performed a non-compliant cast from 'UINT8*' to 'EFI_MEMORY_DESCRIPTOR*'.
Change 'efi_process_memory_map_bootinfo()' function parameter from
'EFI_MEMORY_DESCRIPTOR *' to 'void *' for the memory map parameter. Replace
usage of 'NextMemoryDescriptor()' macro with compliant pointer arithmetic
on 'void *', followed by a single compliant cast to 'EFI_MEMORY_DESCRIPTOR *'.
Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
---
Changes in v2:
- removed 'NextMemoryDescriptor()' macro and used pointer arithmetic like in x86
Link to v1:
https://patchew.org/Xen/78112778d6fd5f720f7102db7125c844b747a962.1761242341.git.dmytro._5Fprokopchuk1@epam.com/
Test CI pipeline:
https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/pipelines/2123465709
---
xen/arch/arm/efi/efi-boot.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h
index 7844b9529e..ea59de47e7 100644
--- a/xen/arch/arm/efi/efi-boot.h
+++ b/xen/arch/arm/efi/efi-boot.h
@@ -191,15 +191,16 @@ static bool __init meminfo_add_bank(struct membanks *mem,
return true;
}
-static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *map,
+static EFI_STATUS __init efi_process_memory_map_bootinfo(void *map,
UINTN mmap_size,
UINTN desc_size)
{
int Index;
- EFI_MEMORY_DESCRIPTOR *desc_ptr = map;
for ( Index = 0; Index < (mmap_size / desc_size); Index++ )
{
+ EFI_MEMORY_DESCRIPTOR *desc_ptr = map + desc_size * Index;
+
if ( !(desc_ptr->Attribute & EFI_MEMORY_RUNTIME) &&
(desc_ptr->Attribute & EFI_MEMORY_WB) &&
(desc_ptr->Type == EfiConventionalMemory ||
@@ -227,7 +228,6 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *
}
}
#endif
- desc_ptr = NextMemoryDescriptor(desc_ptr, desc_size);
}
return EFI_SUCCESS;
--
2.43.0