qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] target/sh4: Return error if CPUClass::get_phys_page_debug()


From: Yoshinori Sato
Subject: Re: [PATCH] target/sh4: Return error if CPUClass::get_phys_page_debug() fails
Date: Thu, 06 May 2021 17:03:23 +0900
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (Gojō) APEL/10.8 EasyPG/1.0.0 Emacs/27 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

On Thu, 06 May 2021 01:10:46 +0900,
Philippe Mathieu-Daudé wrote:
> 
> If the get_physical_address() call fails, the SH4 get_phys_page_debug()
> handler returns an uninitialized address. Instead return -1, which
> correspond to "no page found" (see cpu_get_phys_page_debug() doc
> string).
> 
> This fixes a warning emitted when building with CFLAGS=-O3
> (using GCC 10.2.1 20201125):
> 
>   target/sh4/helper.c: In function ‘superh_cpu_get_phys_page_debug’:
>   target/sh4/helper.c:446:12: warning: ‘physical’ may be used uninitialized 
> in this function [-Wmaybe-uninitialized]
>     446 |     return physical;
>         |            ^~~~~~~~
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  target/sh4/helper.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/target/sh4/helper.c b/target/sh4/helper.c
> index bd8e034f174..2d622081e85 100644
> --- a/target/sh4/helper.c
> +++ b/target/sh4/helper.c
> @@ -441,9 +441,12 @@ hwaddr superh_cpu_get_phys_page_debug(CPUState *cs, 
> vaddr addr)
>      target_ulong physical;
>      int prot;
>  
> -    get_physical_address(&cpu->env, &physical, &prot, addr, MMU_DATA_LOAD);
> +    if (get_physical_address(&cpu->env, &physical, &prot, addr, 
> MMU_DATA_LOAD)
> +            == MMU_OK) {
> +        return physical;
> +    }
>  
> -    return physical;
> +    return -1;
>  }
>  
>  void cpu_load_tlb(CPUSH4State * env)
> -- 
> 2.26.3
> 
> 

Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp>

-- 
Yosinori Sato

reply via email to

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