qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user: Set uninitialized local variable and disable unused code
@ 2011-05-07 20:44 Stefan Weil
  2011-05-07 21:50 ` Peter Maydell
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Weil @ 2011-05-07 20:44 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Riku Voipio

cppcheck report:
linux-user/signal.c:2057: error: Uninitialized variable: err

cppcheck is correct. Setting err = 0 is a workaround to avoid
random results and the cppcheck warning.

Function restore_fpu_state is currently unused, so I disabled the code.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 linux-user/signal.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/linux-user/signal.c b/linux-user/signal.c
index ce033e9..4bda475 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -2027,6 +2027,8 @@ sigsegv:
         unlock_user(sf, sf_addr, sizeof(struct target_signal_frame));
 	force_sig(TARGET_SIGSEGV);
 }
+
+#if 0 /* TODO: function is unused */
 static inline int
 restore_fpu_state(CPUState *env, qemu_siginfo_fpu_t *fpu)
 {
@@ -2053,6 +2055,8 @@ restore_fpu_state(CPUState *env, qemu_siginfo_fpu_t *fpu)
         /* XXX: incorrect */
         err = __copy_from_user(&env->fpr[0], &fpu->si_float_regs[0],
 	                             (sizeof(unsigned long) * 32));
+#else
+        err = 0;
 #endif
         err |= __get_user(env->fsr, &fpu->si_fsr);
 #if 0
@@ -2065,7 +2069,7 @@ restore_fpu_state(CPUState *env, qemu_siginfo_fpu_t *fpu)
 #endif
         return err;
 }
-
+#endif
 
 static void setup_rt_frame(int sig, struct target_sigaction *ka,
                            target_siginfo_t *info,
-- 
1.7.2.5

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

* Re: [Qemu-devel] [PATCH] linux-user: Set uninitialized local variable and disable unused code
  2011-05-07 20:44 [Qemu-devel] [PATCH] linux-user: Set uninitialized local variable and disable unused code Stefan Weil
@ 2011-05-07 21:50 ` Peter Maydell
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Maydell @ 2011-05-07 21:50 UTC (permalink / raw)
  To: Stefan Weil; +Cc: Riku Voipio, QEMU Developers

On 7 May 2011 21:44, Stefan Weil <weil@mail.berlios.de> wrote:
> cppcheck report:
> linux-user/signal.c:2057: error: Uninitialized variable: err
>
> cppcheck is correct. Setting err = 0 is a workaround to avoid
> random results and the cppcheck warning.
>
> Function restore_fpu_state is currently unused, so I disabled the code.

(This is in the SPARC-specific part of that file, to save other
people having to dig through for the relevant ifdef; maybe we
should split it up rather than having every target cpu have
its own huge ifdef-guarded section...)

I'm not sure there's much point in putting in the "err=0"
change as well as ifdef'ing out the function, is there? The
code is clearly broken and whoever fixes it will end up
doing something similar then.

Obviously it would be nicer to actually fix the code, since
at the moment it means if your SPARC binary uses floating
point in a signal handler it can trash registers. Luckily
given where qemu takes guest signals it's quite hard to
actually provoke visible problems with this.

I'm surprised gcc doesn't complain about this.

-- PMM

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

end of thread, other threads:[~2011-05-07 21:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-07 20:44 [Qemu-devel] [PATCH] linux-user: Set uninitialized local variable and disable unused code Stefan Weil
2011-05-07 21:50 ` Peter Maydell

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).