[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] arm/efi: address MISRA C Rule 11.3



commit 6c9b894a586cebf9b5497da574ff3c92a265603d
Author:     Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
AuthorDate: Mon Oct 27 21:12:03 2025 +0000
Commit:     Julien Grall <julien@xxxxxxx>
CommitDate: Sun Nov 16 12:28:26 2025 +0000

    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@xxxxxxxx>
    Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>
---
 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;
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.