From patchwork Mon Nov 21 12:21:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 5231 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 371A623E07 for ; Mon, 21 Nov 2011 12:21:28 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id F2874A18690 for ; Mon, 21 Nov 2011 12:21:27 +0000 (UTC) Received: by ywb5 with SMTP id 5so6409927ywb.11 for ; Mon, 21 Nov 2011 04:21:27 -0800 (PST) Received: by 10.152.144.136 with SMTP id sm8mr8791900lab.33.1321878086890; Mon, 21 Nov 2011 04:21:26 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.41.198 with SMTP id h6cs114674lal; Mon, 21 Nov 2011 04:21:26 -0800 (PST) Received: by 10.216.230.211 with SMTP id j61mr1986751weq.45.1321878084574; Mon, 21 Nov 2011 04:21:24 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id fj5si4513527wbb.91.2011.11.21.04.21.24 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 21 Nov 2011 04:21:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1RSSsC-00081n-0F; Mon, 21 Nov 2011 12:21:20 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Alexander Graf , Riku Voipio Subject: [PATCH] linux-user/strace.c: Correct errno printing for mmap etc Date: Mon, 21 Nov 2011 12:21:19 +0000 Message-Id: <1321878079-30836-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 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); }