From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:34414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSSsQ-00038E-Tu for qemu-devel@nongnu.org; Mon, 21 Nov 2011 07:21:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RSSsM-0003fn-NS for qemu-devel@nongnu.org; Mon, 21 Nov 2011 07:21:34 -0500 Received: from mnementh.archaic.org.uk ([81.2.115.146]:59996) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSSsM-0003fY-Gn for qemu-devel@nongnu.org; Mon, 21 Nov 2011 07:21:30 -0500 From: Peter Maydell Date: Mon, 21 Nov 2011 12:21:19 +0000 Message-Id: <1321878079-30836-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH] linux-user/strace.c: Correct errno printing for mmap etc List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Riku Voipio , Alexander Graf , patches@linaro.org Correct the printing of errnos for syscalls which are handled via print_syscall_ret_addr (mmap, mmap2, brk, shmat): errnos are returned as negative returned values at this level, not via the host 'errno' variable. Signed-off-by: Peter Maydell --- This applies on top of Alex's [v3] linux-user: fix QEMU_STRACE=1 segfault patch. It is fixing a separate bug to that patch, but OTOH it does touch only four lines of actual code, all of which were added in that patch. Keep it separate or fold it in with that one, I don't mind. linux-user/strace.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 269481e..05a0d3e 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -286,11 +285,11 @@ print_syscall_ret_addr(const struct syscallname *name, abi_long ret) { char *errstr = NULL; - if (ret == -1) { - errstr = target_strerror(errno); + if (ret < 0) { + errstr = target_strerror(-ret); } - if ((ret == -1) && errstr) { - gemu_log(" = -1 errno=%d (%s)\n", errno, errstr); + if (errstr) { + gemu_log(" = -1 errno=%d (%s)\n", (int)-ret, errstr); } else { gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret); } -- 1.7.1