]> granicus.if.org Git - strace/commitdiff
Untangle ifdef forest in sys_mmap64. No code changes
authorDenys Vlasenko <dvlasenk@redhat.com>
Fri, 19 Aug 2011 14:11:07 +0000 (16:11 +0200)
committerDenys Vlasenko <dvlasenk@redhat.com>
Tue, 23 Aug 2011 10:53:01 +0000 (12:53 +0200)
After careful analysis, it looks like !LINUX and ALPHA
pass all seven parameters in registers; and in all other cases
parameters are on stack (pointed to by tcp->u_arg[0]).
In light of this, reorganize ifdefs, making them simpler,
without changing any logic.
After this, it's apparent we use tcp->u_arg[4,5,6] and possibly
[7] without checking that it's valid to do so.
So far, just add a comment about this.

* mem.c (sys_mmap64): Rewrite ifdefs in a much simpler way.
Add comments about apparent bugs.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
mem.c

diff --git a/mem.c b/mem.c
index f0ccfc79727a47bb2c78736645c5aa905d7a783b..de9b6bbe38a152fb5490751a5996eea812150067 100644 (file)
--- a/mem.c
+++ b/mem.c
@@ -334,25 +334,15 @@ sys_mmap(struct tcb *tcp)
 int
 sys_mmap64(struct tcb *tcp)
 {
-#ifdef linux
-#ifdef ALPHA
-       long *u_arg = tcp->u_arg;
-#else /* !ALPHA */
-       long u_arg[7];
-#endif /* !ALPHA */
-#else /* !linux */
-       long *u_arg = tcp->u_arg;
-#endif /* !linux */
-
        if (entering(tcp)) {
-#ifdef linux
-#ifndef ALPHA
+#if !defined(LINUX) || defined(ALPHA)
+               long *u_arg = tcp->u_arg;
+#else
+               long u_arg[7];
                if (umoven(tcp, tcp->u_arg[0], sizeof u_arg,
                                (char *) u_arg) == -1)
                        return 0;
-#endif /* ALPHA */
-#endif /* linux */
-
+#endif
                /* addr */
                tprintf("%#lx, ", u_arg[0]);
                /* len */
@@ -369,13 +359,16 @@ sys_mmap64(struct tcb *tcp)
 #endif
                /* fd */
                tprintf(", ");
+       /* BUG?! should be u_arg[4] (without tcp->)? */
                printfd(tcp, tcp->u_arg[4]);
                /* offset */
+       /* BUG?! on non-ALPHA linux, offset will be not in tcp->u_arg,
+        * but in local u_arg, but printllval prints tcp->u_arg! */
                printllval(tcp, ", %#llx", 5);
        }
        return RVAL_HEX;
 }
-#endif
+#endif /* _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T */
 
 
 int