public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [arch/x86/kvm/x86.c:5699]: (error) Uninitialized variable: param
@ 2014-04-26 17:16 Toralf Förster
  2014-04-27  9:53 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Toralf Förster @ 2014-04-26 17:16 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: kvm, x86

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 ?


-- 
Toralf


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [arch/x86/kvm/x86.c:5699]: (error) Uninitialized variable: param
  2014-04-26 17:16 [arch/x86/kvm/x86.c:5699]: (error) Uninitialized variable: param Toralf Förster
@ 2014-04-27  9:53 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2014-04-27  9:53 UTC (permalink / raw)
  To: Toralf Förster, Gleb Natapov; +Cc: kvm, x86

Il 26/04/2014 19:16, Toralf Förster ha scritto:
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-04-27  9:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-26 17:16 [arch/x86/kvm/x86.c:5699]: (error) Uninitialized variable: param Toralf Förster
2014-04-27  9:53 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox