]> granicus.if.org Git - strace/commitdiff
net.c: move parsers of sendmsg and recvmsg syscalls to msghdr.c
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 14 Jul 2016 22:26:28 +0000 (22:26 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 18 Jul 2016 22:12:44 +0000 (22:12 +0000)
* defs.h (fetch_msghdr_namelen, decode_msghdr): Remove.
* net.c (SYS_FUNC(sendmsg), SYS_FUNC(recvmsg)): Move ...
* msghdr.c: ... here.
(fetch_msghdr_namelen, decode_msghdr): Add static qualifier.

defs.h
msghdr.c
net.c

diff --git a/defs.h b/defs.h
index f3847c7e698b1f29cd72f605f1c7a4d13fb6e471..cf55f11432e41f2939ee85093be42c88df0ffd1b 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -609,8 +609,6 @@ extern int printflags64(const struct xlat *, uint64_t, const char *);
 extern const char *sprintflags(const char *, const struct xlat *, uint64_t);
 extern const char *sprintmode(unsigned int);
 extern const char *sprinttime(time_t);
-extern bool fetch_msghdr_namelen(struct tcb *, long, int *);
-extern void decode_msghdr(struct tcb *, const int *, long, unsigned long);
 extern void dumpiov_in_msghdr(struct tcb *, long, unsigned long);
 extern void dumpiov_in_mmsghdr(struct tcb *, long);
 extern void dumpiov_upto(struct tcb *, int, long, unsigned long);
index b805aa33f3a8d35af0c9e8ffee9841c93d70d332..c70a93ae90ef4fac2c92563d2c8ec1b7880042ec 100644 (file)
--- a/msghdr.c
+++ b/msghdr.c
@@ -367,7 +367,7 @@ print_struct_msghdr(struct tcb *tcp, const struct msghdr *msg,
        tprints("}");
 }
 
-bool
+static bool
 fetch_msghdr_namelen(struct tcb *tcp, const long addr, int *const p_msg_namelen)
 {
        struct msghdr msg;
@@ -380,7 +380,7 @@ fetch_msghdr_namelen(struct tcb *tcp, const long addr, int *const p_msg_namelen)
        }
 }
 
-void
+static void
 decode_msghdr(struct tcb *tcp, const int *const p_user_msg_namelen,
              const long addr, const unsigned long data_size)
 {
@@ -400,3 +400,46 @@ dumpiov_in_msghdr(struct tcb *tcp, long addr, unsigned long data_size)
        if (fetch_struct_msghdr(tcp, addr, &msg))
                dumpiov_upto(tcp, msg.msg_iovlen, (long)msg.msg_iov, data_size);
 }
+
+SYS_FUNC(sendmsg)
+{
+       printfd(tcp, tcp->u_arg[0]);
+       tprints(", ");
+       decode_msghdr(tcp, 0, tcp->u_arg[1], (unsigned long) -1L);
+       /* flags */
+       tprints(", ");
+       printflags(msg_flags, tcp->u_arg[2], "MSG_???");
+
+       return RVAL_DECODED;
+}
+
+SYS_FUNC(recvmsg)
+{
+       int msg_namelen;
+
+       if (entering(tcp)) {
+               printfd(tcp, tcp->u_arg[0]);
+               tprints(", ");
+               if (fetch_msghdr_namelen(tcp, tcp->u_arg[1], &msg_namelen)) {
+                       /* abuse of auxstr to retain state */
+                       tcp->auxstr = (void *) (long) msg_namelen;
+                       return 0;
+               }
+               printaddr(tcp->u_arg[1]);
+       } else {
+               msg_namelen = (long) tcp->auxstr;
+               tcp->auxstr = NULL;
+
+               if (syserror(tcp))
+                       tprintf("{msg_namelen=%d}", msg_namelen);
+               else
+                       decode_msghdr(tcp, &msg_namelen, tcp->u_arg[1],
+                                     tcp->u_rval);
+       }
+
+       /* flags */
+       tprints(", ");
+       printflags(msg_flags, tcp->u_arg[2], "MSG_???");
+
+       return RVAL_DECODED;
+}
diff --git a/net.c b/net.c
index a9f51dc24fe5cd3198be72a2319d78ca1a81d00f..47861cf870a353ed4e455bc7bf25b6c0ba18a12b 100644 (file)
--- a/net.c
+++ b/net.c
@@ -281,18 +281,6 @@ SYS_FUNC(sendto)
        return RVAL_DECODED;
 }
 
-SYS_FUNC(sendmsg)
-{
-       printfd(tcp, tcp->u_arg[0]);
-       tprints(", ");
-       decode_msghdr(tcp, 0, tcp->u_arg[1], (unsigned long) -1L);
-       /* flags */
-       tprints(", ");
-       printflags(msg_flags, tcp->u_arg[2], "MSG_???");
-
-       return RVAL_DECODED;
-}
-
 SYS_FUNC(recv)
 {
        if (entering(tcp)) {
@@ -366,37 +354,6 @@ SYS_FUNC(recvfrom)
        return 0;
 }
 
-SYS_FUNC(recvmsg)
-{
-       int msg_namelen;
-
-       if (entering(tcp)) {
-               printfd(tcp, tcp->u_arg[0]);
-               tprints(", ");
-               if (fetch_msghdr_namelen(tcp, tcp->u_arg[1], &msg_namelen)) {
-                       /* abuse of auxstr to retain state */
-                       tcp->auxstr = (void *) (long) msg_namelen;
-                       return 0;
-               }
-               printaddr(tcp->u_arg[1]);
-       } else {
-               msg_namelen = (long) tcp->auxstr;
-               tcp->auxstr = NULL;
-
-               if (syserror(tcp))
-                       tprintf("{msg_namelen=%d}", msg_namelen);
-               else
-                       decode_msghdr(tcp, &msg_namelen, tcp->u_arg[1],
-                                     tcp->u_rval);
-       }
-
-       /* flags */
-       tprints(", ");
-       printflags(msg_flags, tcp->u_arg[2], "MSG_???");
-
-       return RVAL_DECODED;
-}
-
 #include "xlat/shutdown_modes.h"
 
 SYS_FUNC(shutdown)