kvm: avoid bogus vcpu_info assignment in vcpu_register

Also reformat code a bit to make nesting a bit clearer.

Reported by Clang.

* kvm.c (vcpu_register): Do not assign vcpu_alloc result to vcpu_info
as this value is not used afterwards in the function.
This commit is contained in:
Eugene Syromyatnikov 2018-12-18 05:37:30 +01:00
parent 9319e0a49c
commit b083940210

7
kvm.c
View File

@ -96,10 +96,9 @@ vcpu_register(struct tcb *const tcp, int fd, int cpuid)
struct vcpu_info *vcpu_info = vcpu_find(tcp, fd);
if (!vcpu_info)
vcpu_info = vcpu_alloc(tcp, fd, cpuid);
else if (vcpu_info->cpuid != cpuid)
{
if (!vcpu_info) {
vcpu_alloc(tcp, fd, cpuid);
} else if (vcpu_info->cpuid != cpuid) {
vcpu_info->cpuid = cpuid;
vcpu_info->resolved = false;
}