From patchwork Fri Feb 3 14:49:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 139392 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3BCB0104792 for ; Sat, 4 Feb 2012 01:51:21 +1100 (EST) Received: from localhost ([::1]:42459 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtKTs-00024W-AO for incoming@patchwork.ozlabs.org; Fri, 03 Feb 2012 09:51:16 -0500 Received: from eggs.gnu.org ([140.186.70.92]:46253) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtKSR-00087G-25 for qemu-devel@nongnu.org; Fri, 03 Feb 2012 09:49:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RtKSE-0001Ty-VA for qemu-devel@nongnu.org; Fri, 03 Feb 2012 09:49:46 -0500 Received: from afflict.kos.to ([92.243.29.197]:49803) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtKSE-0001Tb-Lj for qemu-devel@nongnu.org; Fri, 03 Feb 2012 09:49:34 -0500 Received: by afflict.kos.to (Postfix, from userid 1000) id 6683C26536; Fri, 3 Feb 2012 14:49:32 +0000 (UTC) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 3 Feb 2012 16:49:23 +0200 Message-Id: <2a7e12455c1d388e41f4c8d2231fb48a968792cd.1328280144.git.riku.voipio@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 92.243.29.197 Cc: Peter Maydell Subject: [Qemu-devel] [PATCH 10/19] linux-user/strace.c: Correct errno printing for mmap etc X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Peter Maydell 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 Signed-off-by: Riku Voipio --- 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); }