[PATCH] KVM: x86: Avoid clang -Wimplicit-fallthrough in kvm_vm_ioctl_check_extension()

From: Nathan Chancellor
Date: Thu Sep 05 2024 - 15:11:13 EST


Clang warns (or errors with CONFIG_WERROR):

arch/x86/kvm/x86.c:4819:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
4819 | default:
| ^

Clang is a little more pedantic than GCC, which does not warn when
falling through to a case that is just break or return. Clang's version
is more in line with the kernel's own stance in deprecated.rst, which
states that all switch/case blocks must end in either break,
fallthrough, continue, goto, or return. Add the missing break to silence
the warning.

Fixes: d30d9ee94cc0 ("KVM: x86: Only advertise KVM_CAP_READONLY_MEM when supported by VM")
Signed-off-by: Nathan Chancellor <nathan@xxxxxxxxxx>
---
arch/x86/kvm/x86.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 0f801804150e..c983c8e434b8 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4816,6 +4816,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
break;
case KVM_CAP_READONLY_MEM:
r = kvm ? kvm_arch_has_readonly_mem(kvm) : 1;
+ break;
default:
break;
}

---
base-commit: 59cbd4eea48fdbc68fc17a29ad71188fea74b28b
change-id: 20240905-kvm-x86-avoid-clang-implicit-fallthrough-6248e3ac5321

Best regards,
--
Nathan Chancellor <nathan@xxxxxxxxxx>