]> granicus.if.org Git - strace/commitdiff
kvm: avoid bogus vcpu_info assignment in vcpu_register
authorEugene Syromyatnikov <evgsyr@gmail.com>
Tue, 18 Dec 2018 04:37:30 +0000 (05:37 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 8 Jul 2019 15:23:36 +0000 (15:23 +0000)
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.

kvm.c

diff --git a/kvm.c b/kvm.c
index 984a75e86b3f9bd908e7b74060eb7dedb61d2ed6..8bdf1cc68556fb226c8ef044ac360b078ce030ae 100644 (file)
--- 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;
        }