Received: from eggs.gnu.org ([2001:4830:134:3::10]:36526) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3lYt-0007li-0L for qemu-devel@nongnu.org; Mon, 29 Jul 2013 07:24:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V3lYp-0001b5-NX for qemu-devel@nongnu.org; Mon, 29 Jul 2013 07:24:22 -0400 From: Peter Maydell Date: Mon, 29 Jul 2013 12:00:31 +0100 Message-Id: <1375095632-13735-2-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1375095632-13735-1-git-send-email-peter.maydell@linaro.org> References: <1375095632-13735-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH for-1.6 1/2] linux-user/signal.c: PPC: Silence clang uninitialized-use warning List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , Riku Voipio , qemu-ppc@nongnu.org, Alexander Graf , patches@linaro.org Silence a clang warning in a PPC signal return function: /home/petmay01/linaro/qemu-from-laptop/qemu/linux-user/signal.c:4611:9: error: variable 'sr_addr' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (!lock_user_struct(VERIFY_READ, sc, sc_addr, 1)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/petmay01/linaro/qemu-from-laptop/qemu/linux-user/signal.c:4636:28: note: uninitialized use occurs here unlock_user_struct(sr, sr_addr, 1); ^~~~~~~ /home/petmay01/linaro/qemu-from-laptop/qemu/linux-user/qemu.h:442:27: note: expanded from macro 'unlock_user_struct' unlock_user(host_ptr, guest_addr, (copy) ? sizeof(*host_ptr) : 0) ^ This happens when we unlock a user struct which we never attempted to lock. Strictly, clang is actually wrong here -- it hasn't been able to spot that unlock_user_struct() doesn't use its second argument if the first is NULL. However it doesn't seem too unreasonable to demand that we pass in initialized values to it. Signed-off-by: Peter Maydell --- linux-user/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index a5e8906..d63777d 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -4603,7 +4603,7 @@ long do_sigreturn(CPUPPCState *env) { struct target_sigcontext *sc = NULL; struct target_mcontext *sr = NULL; - target_ulong sr_addr, sc_addr; + target_ulong sr_addr = 0, sc_addr; sigset_t blocked; target_sigset_t set; -- 1.7.9.5