Skip to contentSkip to conversation

: (error) Uninitialized variable: param

arch/x86/kvm/x86.c:5699 Toralf Förster 2 participants 2 messages Apr 26, 2014 – Apr 27, 2014 KVM

lore
Share & tools
lore
#0 lore raw

cppcheck spotted this - and while it has a lot of false positives in its current version, I do think that the kernel code around that line can be improved:

        longmode = is_long_mode(vcpu) && cs_l == 1;

        if (!longmode) {
                param = ((u64)kvm_register_read(vcpu, VCPU_REGS_RDX) << 32) |
                        (kvm_register_read(vcpu, VCPU_REGS_RAX) & 0xffffffff);
                ingpa = ((u64)kvm_register_read(vcpu, VCPU_REGS_RBX) << 32) |
                        (kvm_register_read(vcpu, VCPU_REGS_RCX) & 0xffffffff);
                outgpa = ((u64)kvm_register_read(vcpu, VCPU_REGS_RDI) << 32) |
                        (kvm_register_read(vcpu, VCPU_REGS_RSI) & 0xffffffff);
        }
#ifdef CONFIG_X86_64
        else {
                param = kvm_register_read(vcpu, VCPU_REGS_RCX);
                ingpa = kvm_register_read(vcpu, VCPU_REGS_RDX);
                outgpa = kvm_register_read(vcpu, VCPU_REGS_R8);
        }

#endif

        code = param & 0xffff;

If CONFIG_X86_64 is not defined then the condition "if (!longmode)" is either superfluous or lacks an else branch, right ?

Signature · 1 line
Toralf
maintainer
#1 lore raw

Il 26/04/2014 19:16, Toralf Förster ha scritto:

Quoted 2 lines

If CONFIG_X86_64 is not defined then the condition "if (!longmode)" is either superfluous or lacks an else branch, right ?

It is superfluous indeed.

Paolo