summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2021-02-15 17:42:01 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2021-02-15 17:42:45 +0100
commitbcd22e145b9a65dd603c7b3d8079e948922787e4 (patch)
tree440ff820d39f58cc78323c837a7e3e01451f700a /tools
parentselftests: kvm: add hardware_disable test (diff)
downloadlinux-bcd22e145b9a65dd603c7b3d8079e948922787e4.tar.xz
linux-bcd22e145b9a65dd603c7b3d8079e948922787e4.zip
selftests: kvm: avoid uninitialized variable warning
The variable in practice will never be uninitialized, because the loop will always go through at least one iteration. In case it would not, make vcpu_get_cpuid report an assertion failure. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/kvm/lib/x86_64/processor.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c
index de0c76177d02..a8906e60a108 100644
--- a/tools/testing/selftests/kvm/lib/x86_64/processor.c
+++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c
@@ -720,7 +720,8 @@ struct kvm_cpuid2 *vcpu_get_cpuid(struct kvm_vm *vm, uint32_t vcpuid)
{
struct vcpu *vcpu = vcpu_find(vm, vcpuid);
struct kvm_cpuid2 *cpuid;
- int rc, max_ent;
+ int max_ent;
+ int rc = -1;
TEST_ASSERT(vcpu != NULL, "vcpu not found, vcpuid: %u", vcpuid);