From: Eugene Syromyatnikov Date: Tue, 18 Dec 2018 04:37:30 +0000 (+0100) Subject: kvm: avoid bogus vcpu_info assignment in vcpu_register X-Git-Tag: v5.2~19 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9446038e9face3313373ca5f7539476789fd4660;p=strace 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. --- diff --git a/kvm.c b/kvm.c index 984a75e8..8bdf1cc6 100644 --- a/kvm.c +++ b/kvm.c @@ -76,10 +76,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; }