Skip to contentSkip to conversation

KVM: x86: Fix clang -Wimplicit-fallthrough in do_host_cpuid()

PATCH Applied Nathan Chancellor 2 participants 2 messages Mar 22, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: x86: Fix clang -Wimplicit-fallthrough in do_host_cpuid()

Clang warns:

arch/x86/kvm/cpuid.c:739:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]

          default:
          ^
  arch/x86/kvm/cpuid.c:739:2: note: insert 'break;' to avoid fall-through
          default:
          ^
          break;

1 error generated.

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 f144c49e8c39 ("KVM: x86: synthesize CPUID leaf 0x80000021h if useful")
---
 arch/x86/kvm/cpuid.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kvm/cpuid.c +1 -0
index 58b0b4e0263c..a3c87d2882ad 100644
@@ -735,6 +735,7 @@ static struct kvm_cpuid_entry2 *do_host_cpuid(struct kvm_cpuid_array *array,
 			if (function > READ_ONCE(max_cpuid_80000000))
 				return entry;
 		}
+		break;
 
 	default:
 		break;

base-commit: c9b8fecddb5bb4b67e351bbaeaa648a6f7456912

Signature · 1 line
2.35.1