diff mbox

[PULL,14/46] cpu-exec: drop dead assignment

Message ID a7fa2e9783ee957635d23ddab151a8be97df5b2a.1423549659.git.mjt@msgid.tls.msk.ru
State New
Headers show

Commit Message

Michael Tokarev Feb. 10, 2015, 6:34 a.m. UTC
From: Paolo Bonzini <pbonzini@redhat.com>

All uses of TB inside cpu_exec are dominated by "tb = tb_find_fast(env)",
and there are no uses after the switch statement.  So the assignment
is dead, as reported by Coverity.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 cpu-exec.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Peter Maydell Feb. 10, 2015, 9:15 a.m. UTC | #1
On 10 February 2015 at 06:34, Michael Tokarev <mjt@tls.msk.ru> wrote:
> From: Paolo Bonzini <pbonzini@redhat.com>
>
> All uses of TB inside cpu_exec are dominated by "tb = tb_find_fast(env)",
> and there are no uses after the switch statement.  So the assignment
> is dead, as reported by Coverity.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
> ---
>  cpu-exec.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/cpu-exec.c b/cpu-exec.c
> index fa506e6..4ff1b23 100644
> --- a/cpu-exec.c
> +++ b/cpu-exec.c
> @@ -494,7 +494,6 @@ int cpu_exec(CPUArchState *env)
>                           * interrupt_request) which we will handle
>                           * next time around the loop.
>                           */
> -                        tb = (TranslationBlock *)(next_tb & ~TB_EXIT_MASK);
>                          next_tb = 0;
>                          break;
>                      case TB_EXIT_ICOUNT_EXPIRED:

True, I guess, but presumably this means we're doing unnecessary
work in the next time round the loop re-finding the tb which we
already had...

(Also, why do we have a variable 'next_tb' which holds the
address of the *previous* TB? :-) I think the documentation
of the return value of tcg_qemu_tb_exec() is wrong too. Or
I've misunderstood the code.)

-- PMM
Paolo Bonzini Feb. 10, 2015, 9:19 a.m. UTC | #2
On 10/02/2015 10:15, Peter Maydell wrote:
> > -                        tb = (TranslationBlock *)(next_tb & ~TB_EXIT_MASK);
> >                          next_tb = 0;
> >                          break;
> >                      case TB_EXIT_ICOUNT_EXPIRED:
>
> True, I guess, but presumably this means we're doing unnecessary
> work in the next time round the loop re-finding the tb which we
> already had...

This is the TB_EXIT_REQUESTED case though: once the iothread runs who
knows what happens.  You might get an interrupt or a system reset that
diverts execution away from tb.

Paolo
diff mbox

Patch

diff --git a/cpu-exec.c b/cpu-exec.c
index fa506e6..4ff1b23 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -494,7 +494,6 @@  int cpu_exec(CPUArchState *env)
                          * interrupt_request) which we will handle
                          * next time around the loop.
                          */
-                        tb = (TranslationBlock *)(next_tb & ~TB_EXIT_MASK);
                         next_tb = 0;
                         break;
                     case TB_EXIT_ICOUNT_EXPIRED: