Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8dd2d2d authored by Valdis Kletnieks's avatar Valdis Kletnieks Committed by Paolo Bonzini
Browse files

Silence compiler warning in arch/x86/kvm/emulate.c



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: default avatarAruna Hewapathirane <aruna.hewapathirane@gmail.com>
Tested-by: default avatarAruna Hewapathirane <aruna.hewapathirane@gmail.com>
Signed-off-by: default avatarValdis Kletnieks <valdis.kletnieks@vt.edu>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent efbb288a
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -650,6 +650,7 @@ static __always_inline int __linearize(struct x86_emulate_ctxt *ctxt,
	u16 sel;
	u16 sel;


	la = seg_base(ctxt, addr.seg) + addr.ea;
	la = seg_base(ctxt, addr.seg) + addr.ea;
	*linear = la;
	*max_size = 0;
	*max_size = 0;
	switch (mode) {
	switch (mode) {
	case X86EMUL_MODE_PROT64:
	case X86EMUL_MODE_PROT64:
@@ -693,7 +694,6 @@ static __always_inline int __linearize(struct x86_emulate_ctxt *ctxt,
	}
	}
	if (insn_aligned(ctxt, size) && ((la & (size - 1)) != 0))
	if (insn_aligned(ctxt, size) && ((la & (size - 1)) != 0))
		return emulate_gp(ctxt, 0);
		return emulate_gp(ctxt, 0);
	*linear = la;
	return X86EMUL_CONTINUE;
	return X86EMUL_CONTINUE;
bad:
bad:
	if (addr.seg == VCPU_SREG_SS)
	if (addr.seg == VCPU_SREG_SS)