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

[xen staging] x86/efi: tidy switch statement and address MISRA violation



commit f509d39d5bb35d2ce200ebe75ad8cbb5f35a7ae2
Author:     Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
AuthorDate: Fri Apr 5 11:14:32 2024 +0200
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Thu Apr 11 13:23:08 2024 +0100

    x86/efi: tidy switch statement and address MISRA violation
    
    Refactor the first clauses so that a violation of
    MISRA C Rule 16.2 is resolved (a switch label, "default" in this
    case, should be immediately enclosed in the compound statement
    of the switch). Note that the switch clause ending with the pseudo
    keyword "fallthrough" is an allowed exception to Rule 16.3.
    
    Convert fallthrough comments in other clauses to the pseudo-keyword
    while at it.
    
    No functional change.
    
    Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/arch/x86/efi/efi-boot.h | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index 8ea64e31cd..f282358435 100644
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -169,20 +169,23 @@ static void __init 
efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable,
 
         switch ( desc->Type )
         {
+        default:
+            type = E820_RESERVED;
+            break;
+
         case EfiBootServicesCode:
         case EfiBootServicesData:
             if ( map_bs )
             {
-        default:
                 type = E820_RESERVED;
                 break;
             }
-            /* fall through */
+            fallthrough;
         case EfiConventionalMemory:
             if ( !trampoline_phys && desc->PhysicalStart + len <= 0x100000 &&
                  len >= cfg.size && desc->PhysicalStart + len > cfg.addr )
                 cfg.addr = (desc->PhysicalStart + len - cfg.size) & PAGE_MASK;
-            /* fall through */
+            fallthrough;
         case EfiLoaderCode:
         case EfiLoaderData:
             if ( desc->Attribute & EFI_MEMORY_RUNTIME )
@@ -190,9 +193,13 @@ static void __init 
efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable,
             else if ( desc->Attribute & EFI_MEMORY_WB )
                 type = E820_RAM;
             else
-        case EfiUnusableMemory:
                 type = E820_UNUSABLE;
             break;
+
+        case EfiUnusableMemory:
+            type = E820_UNUSABLE;
+            break;
+
         case EfiACPIReclaimMemory:
             type = E820_ACPI;
             break;
--
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®.