From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37384) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XowW4-0004lD-FR for qemu-devel@nongnu.org; Thu, 13 Nov 2014 10:41:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XowVv-0007mx-BH for qemu-devel@nongnu.org; Thu, 13 Nov 2014 10:41:00 -0500 Received: from mail-wi0-x22f.google.com ([2a00:1450:400c:c05::22f]:41459) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XowVv-0007mq-5V for qemu-devel@nongnu.org; Thu, 13 Nov 2014 10:40:51 -0500 Received: by mail-wi0-f175.google.com with SMTP id l15so4779034wiw.14 for ; Thu, 13 Nov 2014 07:40:50 -0800 (PST) Received: from playground.station (net-37-117-142-149.cust.vodafonedsl.it. [37.117.142.149]) by mx.google.com with ESMTPSA id u13sm26168441wiv.10.2014.11.13.07.40.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Nov 2014 07:40:49 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 13 Nov 2014 16:40:23 +0100 Message-Id: <1415893228-25823-9-git-send-email-pbonzini@redhat.com> In-Reply-To: <1415893228-25823-1-git-send-email-pbonzini@redhat.com> References: <1415893228-25823-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 08/13] target-i386: eliminate dead code and hoist common code out of "if" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org ist != 0 is checked in the first "if", so it cannot be true in the "else if" part. While at it, simplify the code and move the ESP alignment out of the conditionals. Reported by Coverity. Signed-off-by: Paolo Bonzini --- target-i386/seg_helper.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/target-i386/seg_helper.c b/target-i386/seg_helper.c index af5c1c6..c98eeb4 100644 --- a/target-i386/seg_helper.c +++ b/target-i386/seg_helper.c @@ -883,32 +883,23 @@ static void do_interrupt64(CPUX86State *env, int intno, int is_int, } if ((!(e2 & DESC_C_MASK) && dpl < cpl) || ist != 0) { /* to inner privilege */ - if (ist != 0) { - esp = get_rsp_from_tss(env, ist + 3); - } else { - esp = get_rsp_from_tss(env, dpl); - } - esp &= ~0xfLL; /* align stack */ - ss = 0; new_stack = 1; + esp = get_rsp_from_tss(env, ist != 0 ? ist + 3 : dpl); + ss = 0; } else if ((e2 & DESC_C_MASK) || dpl == cpl) { /* to same privilege */ if (env->eflags & VM_MASK) { raise_exception_err(env, EXCP0D_GPF, selector & 0xfffc); } new_stack = 0; - if (ist != 0) { - esp = get_rsp_from_tss(env, ist + 3); - } else { - esp = env->regs[R_ESP]; - } - esp &= ~0xfLL; /* align stack */ + esp = env->regs[R_ESP]; dpl = cpl; } else { raise_exception_err(env, EXCP0D_GPF, selector & 0xfffc); new_stack = 0; /* avoid warning */ esp = 0; /* avoid warning */ } + esp &= ~0xfLL; /* align stack */ PUSHQ(esp, env->segs[R_SS].selector); PUSHQ(esp, env->regs[R_ESP]); -- 1.8.3.1