]> granicus.if.org Git - strace/commitdiff
kvm: avoid bogus vcpu_info assignment in vcpu_register esyr/next-ng2
authorEugene Syromyatnikov <evgsyr@gmail.com>
Tue, 18 Dec 2018 04:37:30 +0000 (05:37 +0100)
committerEugene Syromyatnikov <evgsyr@gmail.com>
Tue, 18 Dec 2018 04:37:30 +0000 (05:37 +0100)
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 f7cd05f4ea7263ac3ec321f696df3608d10c1310..9d6b646a7ceea309fef526f8ac1be092a1dc247e 100644 (file)
--- a/kvm.c
+++ b/kvm.c
@@ -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;
        }