]> git.proxmox.com Git - qemu.git/commitdiff
linux-user/strace.c: Correct errno printing for mmap etc
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 21 Nov 2011 12:21:19 +0000 (12:21 +0000)
committerRiku Voipio <riku.voipio@linaro.org>
Thu, 2 Feb 2012 15:51:20 +0000 (17:51 +0200)
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 <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user/strace.c

index 269481e7ae18fdb872c4811f5a16de353dbf10fe..05a0d3e9d7fda7d20009690f44d42cb7a2010dda 100644 (file)
@@ -1,5 +1,4 @@
 #include <stdio.h>
-#include <errno.h>
 #include <sys/ipc.h>
 #include <sys/msg.h>
 #include <sys/sem.h>
@@ -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);
     }