From f509d39d5bb35d2ce200ebe75ad8cbb5f35a7ae2 Mon Sep 17 00:00:00 2001 From: Nicola Vetrini Date: Fri, 5 Apr 2024 11:14:32 +0200 Subject: [PATCH] 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 Acked-by: Andrew Cooper --- 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; -- 2.39.5