qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-trivial] [PATCH] cpu-exec: Fix compiler warning (-Werror=clobb


From: Jan Kiszka
Subject: Re: [Qemu-trivial] [PATCH] cpu-exec: Fix compiler warning (-Werror=clobbered)
Date: Tue, 17 Sep 2013 19:17:53 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666

On 2013-09-17 19:03, Stefan Weil wrote:
> 'cpu' and 'env' are not modified after sigsetjmp. Therefore they will
> still have their last value after longjmp restored the stack context.
> 
> The code which should "reload" both variables causes a compiler warning:
> 
> cpu-exec.c:204:15: error:
> variable ‘cpu’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
> cpu-exec.c:202:28: error:
> argument ‘env’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
> 
> Remove this unneeded code.
> 
> Signed-off-by: Stefan Weil <address@hidden>
> ---
> 
> Jan,
> 
> could you please review this patch which removes code added by you earlier?
> I have run tests with the old code and assertions to see whether the values
> were really smashed. They never were, and from the documentation of setjmp
> I'd not expect that they ever might be.
> 
> The patch is needed to fix a compiler warning with -Wextra.

This used to fix a real, deadly crash. Therefore a reversion can't be
trivial by definition. Unfortunately, I don't recall which compiler
version and concrete scenario were involved back then.

Anyway - did anything change in the code structure around since then?
Does anything ensure that this "optimization" is not longer performed by
the compiler?

I'll try to understand the warnings meanwhile.

Jan

> 
> Thanks,
> Stefan
> 
>  cpu-exec.c |    5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/cpu-exec.c b/cpu-exec.c
> index 5a43995..fbfb749 100644
> --- a/cpu-exec.c
> +++ b/cpu-exec.c
> @@ -676,11 +676,6 @@ int cpu_exec(CPUArchState *env)
>                  /* reset soft MMU for next block (it can currently
>                     only be set by a memory fault) */
>              } /* for(;;) */
> -        } else {
> -            /* Reload env after longjmp - the compiler may have smashed all
> -             * local variables as longjmp is marked 'noreturn'. */
> -            cpu = current_cpu;
> -            env = cpu->env_ptr;
>          }
>      } /* for(;;) */
>  
> 


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]