]> granicus.if.org Git - strace/commitdiff
cleanup: make get_syscall_result.c files more readable
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 30 Nov 2015 00:01:01 +0000 (00:01 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 30 Nov 2015 00:01:01 +0000 (00:01 +0000)
Make get_syscall_result.c files more self-contained.  While they are
still being included by syscall.c, the latter no longer provides
a function framework for them.

* linux/alpha/get_syscall_result.c (get_syscall_result_regs): Define.
* linux/bfin/get_syscall_result.c: Likewise.
* linux/crisv10/get_syscall_result.c: Likewise.
* linux/hppa/get_syscall_result.c: Likewise.
* linux/m68k/get_syscall_result.c: Likewise.
* linux/microblaze/get_syscall_result.c: Likewise.
* linux/sh/get_syscall_result.c: Likewise.
* linux/sh64/get_syscall_result.c: Likewise.
* linux/xtensa/get_syscall_result.c: Likewise.
* syscall.c [!ARCH_REGS_FOR_GETREGSET && !ARCH_REGS_FOR_GETREGS]:
Define USE_GET_SYSCALL_RESULT_REGS macro.
[USE_GET_SYSCALL_RESULT_REGS]: Include "get_syscall_result.c".
(get_syscall_result) [USE_GET_SYSCALL_RESULT_REGS]: Stop including
"get_syscall_result.c".  Call get_syscall_result_regs.

Requested-by: Denys Vlasenko <dvlasenk@redhat.com>
linux/alpha/get_syscall_result.c
linux/bfin/get_syscall_result.c
linux/crisv10/get_syscall_result.c
linux/hppa/get_syscall_result.c
linux/m68k/get_syscall_result.c
linux/microblaze/get_syscall_result.c
linux/sh/get_syscall_result.c
linux/sh64/get_syscall_result.c
linux/xtensa/get_syscall_result.c
syscall.c

index 11e273623c5027d84f78cbad18030065e69bb958..f4c504f1589b5061d72a2e4f097104d45e9103f1 100644 (file)
@@ -1,4 +1,6 @@
-if (upeek(tcp->pid, REG_A3, &alpha_a3) < 0)
-       return -1;
-if (upeek(tcp->pid, REG_R0, &alpha_r0) < 0)
-       return -1;
+static int
+get_syscall_result_regs(struct tcb *tcp)
+{
+       return (upeek(tcp->pid, REG_A3, &alpha_a3) < 0 ||
+               upeek(tcp->pid, REG_R0, &alpha_r0) < 0) ? -1 : 0;
+}
index c9d94d480ddfae2f8547afbe5d6006235307ee9d..c189a5fd8f73358b57e90a328ba8143c8488bb2e 100644 (file)
@@ -1,2 +1,5 @@
-if (upeek(tcp->pid, PT_R0, &bfin_r0) < 0)
-       return -1;
+static int
+get_syscall_result_regs(struct tcb *tcp)
+{
+       return upeek(tcp->pid, PT_R0, &bfin_r0) < 0 ? -1 : 0;
+}
index 53b087a3e93e53c8126d665d616c99b22861b618..6b3679c15b93c5a8297761a195fec7a15b198cc0 100644 (file)
@@ -1,2 +1,5 @@
-if (upeek(tcp->pid, 4*PT_R10, &cris_r10) < 0)
-       return -1;
+static int
+get_syscall_result_regs(struct tcb *tcp)
+{
+       return upeek(tcp->pid, 4 * PT_R10, &cris_r10) < 0 ? -1 : 0;
+}
index d929b9f18e4c7aee174de7f7d2e3a83438b11013..0d15d4db7001f46d0b46b1e34c66c74efca82a23 100644 (file)
@@ -1,2 +1,5 @@
-if (upeek(tcp->pid, PT_GR28, &hppa_r28) < 0)
-       return -1;
+static int
+get_syscall_result_regs(struct tcb *tcp)
+{
+       return upeek(tcp->pid, PT_GR28, &hppa_r28) < 0 ? -1 : 0;
+}
index fc452b49a836a0bddbc1d260eb0d43820fd29448..005cf60cd74dc9d4460bf36efa92ae36a30a53ca 100644 (file)
@@ -1,2 +1,5 @@
-if (upeek(tcp->pid, 4*PT_D0, &m68k_d0) < 0)
-       return -1;
+static int
+get_syscall_result_regs(struct tcb *tcp)
+{
+       return upeek(tcp->pid, 4 * PT_D0, &m68k_d0) < 0 ? -1 : 0;
+}
index b7ec27f29d9e2540105319ff02d939f48d1f2c3b..9ece53e82e9eb263895fe551bbb8023fbdeb1c82 100644 (file)
@@ -1,2 +1,5 @@
-if (upeek(tcp->pid, 3 * 4, &microblaze_r3) < 0)
-       return -1;
+static int
+get_syscall_result_regs(struct tcb *tcp)
+{
+       return upeek(tcp->pid, 3 * 4, &microblaze_r3) < 0 ? -1 : 0;
+}
index 3ee0546735c5f568e1eda5e06e8ebe9d35c48692..5db3025489558526d652843f51f1602b4b79ef95 100644 (file)
@@ -1,3 +1,6 @@
-/* new syscall ABI returns result in R0 */
-if (upeek(tcp->pid, 4*REG_REG0, (long *)&sh_r0) < 0)
-       return -1;
+static int
+get_syscall_result_regs(struct tcb *tcp)
+{
+       /* new syscall ABI returns result in R0 */
+       return upeek(tcp->pid, 4 * REG_REG0, (long *)&sh_r0) < 0 ? -1 : 0;
+}
index e53bd0f47e3c8b4d7a37ebb027da6eb66091ded6..93faf3dfcdec13086c5f65d1adec092129b2d206 100644 (file)
@@ -1,3 +1,6 @@
-/* ABI defines result returned in r9 */
-if (upeek(tcp->pid, REG_GENERAL(9), (long *)&sh64_r9) < 0)
-       return -1;
+static int
+get_syscall_result_regs(struct tcb *tcp)
+{
+       /* ABI defines result returned in r9 */
+       return upeek(tcp->pid, REG_GENERAL(9), (long *)&sh64_r9) < 0 ? -1 : 0;
+}
index 0d2e697cde10003705eb96bedef5c1428b6553e7..51ad6deab218d06980b833b4ed420befa1d05246 100644 (file)
@@ -1,2 +1,5 @@
-if (upeek(tcp->pid, REG_A_BASE + 2, &xtensa_a2) < 0)
-       return -1;
+static int
+get_syscall_result_regs(struct tcb *tcp)
+{
+       return upeek(tcp->pid, REG_A_BASE + 2, &xtensa_a2) < 0 ? -1 : 0;
+}
index 34627f255793e1664a2460b9779e21a29874962b..9cf3fc54eaca7cf85fe54be0bcb6b94e53df4cf9 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -1253,6 +1253,7 @@ get_regset(pid_t pid)
 void
 get_regs(pid_t pid)
 {
+#undef USE_GET_SYSCALL_RESULT_REGS
 #ifdef ARCH_REGS_FOR_GETREGSET
 # ifdef X86_64
        /* Try PTRACE_GETREGSET first, fallback to PTRACE_GETREGS. */
@@ -1295,7 +1296,8 @@ get_regs(pid_t pid)
 # endif
 
 #else /* !ARCH_REGS_FOR_GETREGSET && !ARCH_REGS_FOR_GETREGS */
-#  warning get_regs is not implemented for this architecture yet
+# define USE_GET_SYSCALL_RESULT_REGS 1
+# warning get_regs is not implemented for this architecture yet
        get_regs_error = 0;
 #endif
 }
@@ -1343,6 +1345,9 @@ get_syscall_args(struct tcb *tcp)
        return 1;
 }
 
+#ifdef USE_GET_SYSCALL_RESULT_REGS
+# include "get_syscall_result.c"
+#endif
 #include "get_error.c"
 
 /* Returns:
@@ -1353,10 +1358,9 @@ get_syscall_args(struct tcb *tcp)
 static int
 get_syscall_result(struct tcb *tcp)
 {
-#if defined ARCH_REGS_FOR_GETREGSET || defined ARCH_REGS_FOR_GETREGS
-       /* already done by get_regs */
-#else
-# include "get_syscall_result.c"
+#ifdef USE_GET_SYSCALL_RESULT_REGS
+       if (get_syscall_result_regs(tcp))
+               return -1;
 #endif
        tcp->u_error = 0;
        get_error(tcp, !(tcp->s_ent->sys_flags & SYSCALL_NEVER_FAILS));