qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] target-mips: Fix warning caused by unused local variable
@ 2011-05-08  8:24 Stefan Weil
  2011-05-14 23:01 ` Aurelien Jarno
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Weil @ 2011-05-08  8:24 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Aurelien Jarno

cppcheck report:
target-mips/helper.c:276: style:
 Variable 'access_type' is assigned a value that is never used

'access_type' is only used for system emulation, so the patch
simply fixes the conditional compilation.

There remains an issue with the return value 'ret' in user mode emulation.
The assignment ret = TLBRET_NOMATCH is without effect because there is
a ret = 1 later. Which one is correct?

Cc: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 target-mips/helper.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/target-mips/helper.c b/target-mips/helper.c
index bdc1e53..f3cd521 100644
--- a/target-mips/helper.c
+++ b/target-mips/helper.c
@@ -272,8 +272,8 @@ int cpu_mips_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
 #if !defined(CONFIG_USER_ONLY)
     target_phys_addr_t physical;
     int prot;
-#endif
     int access_type;
+#endif
     int ret = 0;
 
 #if 0
@@ -284,13 +284,13 @@ int cpu_mips_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
 
     rw &= 1;
 
+#if defined(CONFIG_USER_ONLY)
+    ret = TLBRET_NOMATCH;
+#else
     /* data access */
     /* XXX: put correct access by using cpu_restore_state()
        correctly */
     access_type = ACCESS_INT;
-#if defined(CONFIG_USER_ONLY)
-    ret = TLBRET_NOMATCH;
-#else
     ret = get_physical_address(env, &physical, &prot,
                                address, rw, access_type);
     qemu_log("%s address=" TARGET_FMT_lx " ret %d physical " TARGET_FMT_plx " prot %d\n",
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] target-mips: Fix warning caused by unused local variable
  2011-05-08  8:24 [Qemu-devel] [PATCH] target-mips: Fix warning caused by unused local variable Stefan Weil
@ 2011-05-14 23:01 ` Aurelien Jarno
  0 siblings, 0 replies; 2+ messages in thread
From: Aurelien Jarno @ 2011-05-14 23:01 UTC (permalink / raw)
  To: Stefan Weil; +Cc: QEMU Developers

On Sun, May 08, 2011 at 10:24:39AM +0200, Stefan Weil wrote:
> cppcheck report:
> target-mips/helper.c:276: style:
>  Variable 'access_type' is assigned a value that is never used
> 
> 'access_type' is only used for system emulation, so the patch
> simply fixes the conditional compilation.
> 
> There remains an issue with the return value 'ret' in user mode emulation.
> The assignment ret = TLBRET_NOMATCH is without effect because there is
> a ret = 1 later. Which one is correct?

ret = 1 is the correct version.

I have applied a slightly different patch also fixing the ret issue.

> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
> ---
>  target-mips/helper.c |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/target-mips/helper.c b/target-mips/helper.c
> index bdc1e53..f3cd521 100644
> --- a/target-mips/helper.c
> +++ b/target-mips/helper.c
> @@ -272,8 +272,8 @@ int cpu_mips_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
>  #if !defined(CONFIG_USER_ONLY)
>      target_phys_addr_t physical;
>      int prot;
> -#endif
>      int access_type;
> +#endif
>      int ret = 0;
>  
>  #if 0
> @@ -284,13 +284,13 @@ int cpu_mips_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
>  
>      rw &= 1;
>  
> +#if defined(CONFIG_USER_ONLY)
> +    ret = TLBRET_NOMATCH;
> +#else
>      /* data access */
>      /* XXX: put correct access by using cpu_restore_state()
>         correctly */
>      access_type = ACCESS_INT;
> -#if defined(CONFIG_USER_ONLY)
> -    ret = TLBRET_NOMATCH;
> -#else
>      ret = get_physical_address(env, &physical, &prot,
>                                 address, rw, access_type);
>      qemu_log("%s address=" TARGET_FMT_lx " ret %d physical " TARGET_FMT_plx " prot %d\n",
> -- 
> 1.7.2.5
> 
> 
> 

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-05-14 23:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-08  8:24 [Qemu-devel] [PATCH] target-mips: Fix warning caused by unused local variable Stefan Weil
2011-05-14 23:01 ` Aurelien Jarno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).