]> granicus.if.org Git - strace/blobdiff - desc.c
io.c: use printaddr and umove_or_printaddr
[strace] / desc.c
diff --git a/desc.c b/desc.c
index 24de51deddfc32f5ea39fc1215bec42d6c5dcbb6..e1d01dc4e9d822a1c810a73f7f1e6471849fd5fb 100644 (file)
--- a/desc.c
+++ b/desc.c
@@ -145,8 +145,7 @@ printflock(struct tcb *tcp, long addr, int getlk)
                tprints("}");
 }
 
-int
-sys_fcntl(struct tcb *tcp)
+SYS_FUNC(fcntl)
 {
        if (entering(tcp)) {
                printfd(tcp, tcp->u_arg[0]);
@@ -244,8 +243,7 @@ sys_fcntl(struct tcb *tcp)
 
 #ifdef LOCK_SH
 
-int
-sys_flock(struct tcb *tcp)
+SYS_FUNC(flock)
 {
        if (entering(tcp)) {
                printfd(tcp, tcp->u_arg[0]);
@@ -256,8 +254,7 @@ sys_flock(struct tcb *tcp)
 }
 #endif /* LOCK_SH */
 
-int
-sys_close(struct tcb *tcp)
+SYS_FUNC(close)
 {
        if (entering(tcp)) {
                printfd(tcp, tcp->u_arg[0]);
@@ -265,8 +262,7 @@ sys_close(struct tcb *tcp)
        return 0;
 }
 
-int
-sys_dup(struct tcb *tcp)
+SYS_FUNC(dup)
 {
        if (entering(tcp)) {
                printfd(tcp, tcp->u_arg[0]);
@@ -289,21 +285,18 @@ do_dup2(struct tcb *tcp, int flags_arg)
        return RVAL_FD;
 }
 
-int
-sys_dup2(struct tcb *tcp)
+SYS_FUNC(dup2)
 {
        return do_dup2(tcp, -1);
 }
 
-int
-sys_dup3(struct tcb *tcp)
+SYS_FUNC(dup3)
 {
        return do_dup2(tcp, 2);
 }
 
 #if defined(ALPHA)
-int
-sys_getdtablesize(struct tcb *tcp)
+SYS_FUNC(getdtablesize)
 {
        return 0;
 }
@@ -338,11 +331,8 @@ decode_select(struct tcb *tcp, long *args, enum bitness_t bitness)
        if (entering(tcp)) {
                tprintf("%d", (int) args[0]);
 
-               if (verbose(tcp) && fdsize > 0) {
-                       fds = malloc(fdsize);
-                       if (!fds)
-                               die_out_of_memory();
-               }
+               if (verbose(tcp) && fdsize > 0)
+                       fds = xmalloc(fdsize);
                for (i = 0; i < 3; i++) {
                        arg = args[i+1];
                        if (arg == 0) {
@@ -353,7 +343,7 @@ decode_select(struct tcb *tcp, long *args, enum bitness_t bitness)
                                tprintf(", %#lx", arg);
                                continue;
                        }
-                       if (umoven(tcp, arg, fdsize, (char *) fds) < 0) {
+                       if (umoven(tcp, arg, fdsize, fds) < 0) {
                                tprints(", [?]");
                                continue;
                        }
@@ -387,9 +377,7 @@ decode_select(struct tcb *tcp, long *args, enum bitness_t bitness)
                        return RVAL_STR;
                }
 
-               fds = malloc(fdsize);
-               if (!fds)
-                       die_out_of_memory();
+               fds = xmalloc(fdsize);
 
                outptr = outstr;
                sep = "";
@@ -397,7 +385,7 @@ decode_select(struct tcb *tcp, long *args, enum bitness_t bitness)
                        int first = 1;
 
                        arg = args[i+1];
-                       if (!arg || umoven(tcp, arg, fdsize, (char *) fds) < 0)
+                       if (!arg || umoven(tcp, arg, fdsize, fds) < 0)
                                continue;
                        for (j = 0;; j++) {
                                j = next_set_bit(fds, j, nfds);
@@ -440,12 +428,11 @@ decode_select(struct tcb *tcp, long *args, enum bitness_t bitness)
        return 0;
 }
 
-int
-sys_oldselect(struct tcb *tcp)
+SYS_FUNC(oldselect)
 {
        long args[5];
 
-       if (umoven(tcp, tcp->u_arg[0], sizeof args, (char *) args) < 0) {
+       if (umoven(tcp, tcp->u_arg[0], sizeof args, args) < 0) {
                tprints("[...]");
                return 0;
        }
@@ -453,8 +440,7 @@ sys_oldselect(struct tcb *tcp)
 }
 
 #ifdef ALPHA
-int
-sys_osf_select(struct tcb *tcp)
+SYS_FUNC(osf_select)
 {
        long *args = tcp->u_arg;
        return decode_select(tcp, args, BITNESS_32);
@@ -466,14 +452,12 @@ sys_osf_select(struct tcb *tcp)
 #include "xlat/epollflags.h"
 
 /* Not aliased to printargs_ld: we want it to have a distinct address */
-int
-sys_epoll_create(struct tcb *tcp)
+SYS_FUNC(epoll_create)
 {
        return printargs_ld(tcp);
 }
 
-int
-sys_epoll_create1(struct tcb *tcp)
+SYS_FUNC(epoll_create1)
 {
        if (entering(tcp))
                printflags(epollflags, tcp->u_arg[0], "EPOLL_???");
@@ -493,8 +477,7 @@ print_epoll_event(struct epoll_event *ev)
 }
 #endif
 
-int
-sys_epoll_ctl(struct tcb *tcp)
+SYS_FUNC(epoll_ctl)
 {
        if (entering(tcp)) {
                printfd(tcp, tcp->u_arg[0]);
@@ -563,15 +546,13 @@ epoll_wait_common(struct tcb *tcp)
        }
 }
 
-int
-sys_epoll_wait(struct tcb *tcp)
+SYS_FUNC(epoll_wait)
 {
        epoll_wait_common(tcp);
        return 0;
 }
 
-int
-sys_epoll_pwait(struct tcb *tcp)
+SYS_FUNC(epoll_pwait)
 {
        epoll_wait_common(tcp);
        if (exiting(tcp)) {
@@ -583,14 +564,12 @@ sys_epoll_pwait(struct tcb *tcp)
        return 0;
 }
 
-int
-sys_select(struct tcb *tcp)
+SYS_FUNC(select)
 {
        return decode_select(tcp, tcp->u_arg, BITNESS_CURRENT);
 }
 
-int
-sys_pselect6(struct tcb *tcp)
+SYS_FUNC(pselect6)
 {
        int rc = decode_select(tcp, tcp->u_arg, BITNESS_CURRENT);
        if (entering(tcp)) {
@@ -636,20 +615,17 @@ do_eventfd(struct tcb *tcp, int flags_arg)
        return 0;
 }
 
-int
-sys_eventfd(struct tcb *tcp)
+SYS_FUNC(eventfd)
 {
        return do_eventfd(tcp, -1);
 }
 
-int
-sys_eventfd2(struct tcb *tcp)
+SYS_FUNC(eventfd2)
 {
        return do_eventfd(tcp, 1);
 }
 
-int
-sys_perf_event_open(struct tcb *tcp)
+SYS_FUNC(perf_event_open)
 {
        if (entering(tcp)) {
                tprintf("%#lx, %d, %d, %d, ",