* [Qemu-devel] [PATCH] linux-user/strace.c: Correct errno printing for mmap etc
@ 2011-11-21 12:21 Peter Maydell
2011-11-23 13:15 ` Riku Voipio
0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2011-11-21 12:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Alexander Graf, patches
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>
---
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 <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);
}
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user/strace.c: Correct errno printing for mmap etc
2011-11-21 12:21 [Qemu-devel] [PATCH] linux-user/strace.c: Correct errno printing for mmap etc Peter Maydell
@ 2011-11-23 13:15 ` Riku Voipio
2011-11-23 13:18 ` Alexander Graf
0 siblings, 1 reply; 3+ messages in thread
From: Riku Voipio @ 2011-11-23 13:15 UTC (permalink / raw)
To: Peter Maydell; +Cc: Alexander Graf, qemu-devel, patches
On Mon, Nov 21, 2011 at 12:21:19PM +0000, Peter Maydell wrote:
> 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>
> ---
> 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.
I think in general it is recommended to squash patches that only change lines
added in the previous patch. Otoh it muddies the authorship of the change.
Thus, unless someone objects, I'll que these as separate patches so both
of you get clear credit.
Riku
> 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 <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);
> }
> --
> 1.7.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user/strace.c: Correct errno printing for mmap etc
2011-11-23 13:15 ` Riku Voipio
@ 2011-11-23 13:18 ` Alexander Graf
0 siblings, 0 replies; 3+ messages in thread
From: Alexander Graf @ 2011-11-23 13:18 UTC (permalink / raw)
To: Riku Voipio; +Cc: Peter Maydell, qemu-devel, patches
On 11/23/2011 02:15 PM, Riku Voipio wrote:
> On Mon, Nov 21, 2011 at 12:21:19PM +0000, Peter Maydell wrote:
>> 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>
>> ---
>> 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.
> I think in general it is recommended to squash patches that only change lines
> added in the previous patch. Otoh it muddies the authorship of the change.
> Thus, unless someone objects, I'll que these as separate patches so both
> of you get clear credit.
I am completely indifferent :).
Alex
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-11-23 13:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-21 12:21 [Qemu-devel] [PATCH] linux-user/strace.c: Correct errno printing for mmap etc Peter Maydell
2011-11-23 13:15 ` Riku Voipio
2011-11-23 13:18 ` Alexander Graf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).