public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>,
	Gleb Natapov <gleb@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arch: x86: kvm: x86.c:  Cleaning up uninitialized variables
Date: Tue, 03 Jun 2014 14:04:04 +0200	[thread overview]
Message-ID: <538DB9B4.2070607@redhat.com> (raw)
In-Reply-To: <1401577506-4112-1-git-send-email-rickard_strandqvist@spectrumdigital.se>

Il 01/06/2014 01:05, Rickard Strandqvist ha scritto:
> There is a risk that the variable will be used without being initialized.
> 
> This was largely found by using a static code analysis program called cppcheck.
> 
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>

No, there isn't.  The full context looks like this:

        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

and longmode must be zero if !CONFIG_X86_64:

static inline int is_long_mode(struct kvm_vcpu *vcpu)
{
#ifdef CONFIG_X86_64
        return vcpu->arch.efer & EFER_LMA;
#else
        return 0;
#endif
}

So it's the static checker that cannot understand #ifdef well
enough and ought to be fixed.

Paolo

  reply	other threads:[~2014-06-03 12:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-31 23:05 [PATCH] arch: x86: kvm: x86.c: Cleaning up uninitialized variables Rickard Strandqvist
2014-06-03 12:04 ` Paolo Bonzini [this message]
2014-06-03 13:06   ` Michael Tokarev
2014-06-03 13:11     ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=538DB9B4.2070607@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=gleb@kernel.org \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rickard_strandqvist@spectrumdigital.se \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox