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

[xen master] x86/EFI: adjust efi_multiboot2_prelude() to comply to Misra rule 18.2



commit 04d4312440e2c0ea9410eb13a42bdfb38e1493b1
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Thu Sep 10 09:01:30 2026 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Sep 10 09:01:30 2026 +0200

    x86/EFI: adjust efi_multiboot2_prelude() to comply to Misra rule 18.2
    
    While casting to pointer types may be more natural there, the subtraction
    then ends up violating "Subtraction between pointers shall only be applied
    to pointers that address elements of the same array". Use unsigned long
    arithmetic instead.
    
    No functional change intended.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
---
 xen/arch/x86/efi/mbi2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/efi/mbi2.c b/xen/arch/x86/efi/mbi2.c
index d2f0f0ee61..996eafa03d 100644
--- a/xen/arch/x86/efi/mbi2.c
+++ b/xen/arch/x86/efi/mbi2.c
@@ -13,7 +13,7 @@ efi_multiboot2_prelude(uint32_t magic, const 
multiboot2_fixed_t *mbi)
     EFI_HANDLE ImageHandle = NULL;
     EFI_SYSTEM_TABLE *SystemTable = NULL;
     const char *cmdline = NULL;
-    const void *const mbi_raw = (const void *)mbi;
+    unsigned long mbi_raw = (unsigned long)mbi;
     bool have_bs = false;
 
     if ( magic != MULTIBOOT2_BOOTLOADER_MAGIC )
@@ -22,10 +22,10 @@ efi_multiboot2_prelude(uint32_t magic, const 
multiboot2_fixed_t *mbi)
     /* Skip Multiboot2 information fixed part. */
     tag = _p(ROUNDUP((unsigned long)(mbi + 1), MULTIBOOT2_TAG_ALIGN));
 
-    for ( ; (const void *)(tag + 1) - mbi_raw <= mbi->total_size &&
+    for ( ; (unsigned long)(tag + 1) - mbi_raw <= mbi->total_size &&
             tag->type != MULTIBOOT2_TAG_TYPE_END &&
             tag->size >= sizeof(*tag) &&
-            (const void *)tag + tag->size - mbi_raw <= mbi->total_size;
+            (unsigned long)tag + tag->size - mbi_raw <= mbi->total_size;
           tag = _p(ROUNDUP((unsigned long)tag + tag->size,
                    MULTIBOOT2_TAG_ALIGN)) )
     {
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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