arm/efi: address MISRA C Rule 11.3

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>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
This commit is contained in:
Dmytro Prokopchuk1 authored and Julien Grall committed 2025-11-16 12:28:26 +00:00
1 parent b27eedee70
commit 6c9b894a58
1 file changed
+3 -3
+3 -3
View File
@@ -191,15 +191,16 @@ static bool __init meminfo_add_bank(struct membanks *mem,
return true; 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 mmap_size,
UINTN desc_size) UINTN desc_size)
{ {
int Index; int Index;
EFI_MEMORY_DESCRIPTOR *desc_ptr = map;
for ( Index = 0; Index < (mmap_size / desc_size); Index++ ) 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) && if ( !(desc_ptr->Attribute & EFI_MEMORY_RUNTIME) &&
(desc_ptr->Attribute & EFI_MEMORY_WB) && (desc_ptr->Attribute & EFI_MEMORY_WB) &&
(desc_ptr->Type == EfiConventionalMemory || (desc_ptr->Type == EfiConventionalMemory ||
@@ -227,7 +228,6 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *
} }
} }
#endif #endif
desc_ptr = NextMemoryDescriptor(desc_ptr, desc_size);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.