From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752648AbbH2Vua (ORCPT ); Sat, 29 Aug 2015 17:50:30 -0400 Received: from outbound.smtp.vt.edu ([198.82.183.121]:45013 "EHLO omr2.cc.vt.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752222AbbH2Vu3 (ORCPT ); Sat, 29 Aug 2015 17:50:29 -0400 X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.6+dev To: Gleb Natapov , Paolo Bonzini cc: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Aruna Hewapathirane Subject: Silence compiler warning in arch/x86/kvm/emulate.c From: Valdis Kletnieks Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 29 Aug 2015 17:49:16 -0400 Message-ID: <142668.1440884956@turing-police.cc.vt.edu> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Compiler warning: CC [M] arch/x86/kvm/emulate.o arch/x86/kvm/emulate.c: In function "__do_insn_fetch_bytes": arch/x86/kvm/emulate.c:814:9: warning: "linear" may be used uninitialized in this function [-Wmaybe-uninitialized] GCC is smart enough to realize that the inlined __linearize may return before setting the value of linear, but not smart enough to realize the same X86EMU_CONTINUE blocks actual use of the value. However, the value of 'linear' can only be set to one value, so hoisting the one line of code upwards makes GCC happy with the code. Reported-by: Aruna Hewapathirane Tested-by: Aruna Hewapathirane Signed-off-by: Valdis Kletnieks --- a/arch/x86/kvm/emulate.c.dist 2015-08-11 14:10:05.366061993 -0400 +++ b/arch/x86/kvm/emulate.c 2015-08-29 13:43:13.014163958 -0400 @@ -650,6 +650,7 @@ static __always_inline int __linearize(s u16 sel; la = seg_base(ctxt, addr.seg) + addr.ea; + *linear = la; *max_size = 0; switch (mode) { case X86EMUL_MODE_PROT64: @@ -693,7 +694,6 @@ static __always_inline int __linearize(s } if (insn_aligned(ctxt, size) && ((la & (size - 1)) != 0)) return emulate_gp(ctxt, 0); - *linear = la; return X86EMUL_CONTINUE; bad: if (addr.seg == VCPU_SREG_SS)