From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH] arch: x86: kvm: x86.c: Cleaning up uninitialized variables Date: Tue, 03 Jun 2014 14:04:04 +0200 Message-ID: <538DB9B4.2070607@redhat.com> References: <1401577506-4112-1-git-send-email-rickard_strandqvist@spectrumdigital.se> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org To: Rickard Strandqvist , Gleb Natapov Return-path: In-Reply-To: <1401577506-4112-1-git-send-email-rickard_strandqvist@spectrumdigital.se> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org 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 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