diff --git a/net.c b/net.c index 245cae9a..bd11741e 100644 --- a/net.c +++ b/net.c @@ -225,7 +225,7 @@ decode_sockname(struct tcb *tcp) tprintf(", [%d]", ulen); } else { decode_sockaddr(tcp, tcp->u_arg[1], ulen > rlen ? rlen : ulen); - if (ulen < rlen) + if (ulen != rlen) tprintf(", [%d->%d]", ulen, rlen); else tprintf(", [%d]", rlen); diff --git a/tests/net-y-unix.c b/tests/net-y-unix.c index cb22c438..3efc2f64 100644 --- a/tests/net-y-unix.c +++ b/tests/net-y-unix.c @@ -84,8 +84,8 @@ main(int ac, const char **av) if (getsockname(listen_fd, listen_sa, len)) perror_msg_and_fail("getsockname"); printf("getsockname(%d, {sa_family=AF_UNIX" - ", sun_path=\"%s\"}, [%u]) = 0\n", listen_fd, listen_inode, - av[1], (unsigned) *len); + ", sun_path=\"%s\"}, [%d->%d]) = 0\n", listen_fd, listen_inode, + av[1], (int) sizeof(addr), (int) *len); int connect_fd = socket(AF_UNIX, SOCK_STREAM, 0); if (connect_fd < 0) @@ -108,8 +108,9 @@ main(int ac, const char **av) perror_msg_and_fail("accept"); unsigned long accept_inode = inode_of_sockfd(accept_fd); printf("accept(%d, {sa_family=AF_UNIX}" - ", [%u]) = %d\n", - listen_fd, listen_inode, (unsigned) *len, + ", [%d->%d]) = %d\n", + listen_fd, listen_inode, + (int) sizeof(addr), (int) *len, accept_fd, accept_inode); memset(listen_sa, 0, sizeof(addr)); @@ -117,8 +118,8 @@ main(int ac, const char **av) if (getpeername(connect_fd, listen_sa, len)) perror_msg_and_fail("getpeername"); printf("getpeername(%d, {sa_family=AF_UNIX" - ", sun_path=\"%s\"}, [%u]) = 0\n", connect_fd, connect_inode, - av[1], (unsigned) *len); + ", sun_path=\"%s\"}, [%d->%d]) = 0\n", connect_fd, connect_inode, + av[1], (int) sizeof(addr), (int) *len); char text[] = "text"; assert(sendto(connect_fd, text, sizeof(text) - 1, MSG_DONTWAIT, NULL, 0) @@ -161,8 +162,9 @@ main(int ac, const char **av) if (getsockname(listen_fd, listen_sa, len)) perror_msg_and_fail("getsockname"); printf("getsockname(%d, {sa_family=AF_UNIX" - ", sun_path=\"%s\"}, [%u]) = 0\n", - listen_fd, listen_inode, av[1], (unsigned) *len); + ", sun_path=\"%s\"}, [%d->%d]) = 0\n", + listen_fd, listen_inode, av[1], + (int) sizeof(addr), (int) *len); if (connect(connect_fd, listen_sa, *len)) perror_msg_and_fail("connect"); @@ -179,8 +181,9 @@ main(int ac, const char **av) const char * const sun_path1 = ((struct sockaddr_un *) accept_sa) -> sun_path + 1; printf("accept(%d, {sa_family=AF_UNIX" - ", sun_path=@\"%s\"}, [%u]) = %d\n", - listen_fd, listen_inode, sun_path1, (unsigned) *len, + ", sun_path=@\"%s\"}, [%d->%d]) = %d\n", + listen_fd, listen_inode, sun_path1, + (int) sizeof(addr), (int) *len, accept_fd, accept_inode); memset(listen_sa, 0, sizeof(addr)); @@ -188,16 +191,18 @@ main(int ac, const char **av) if (getpeername(connect_fd, listen_sa, len)) perror_msg_and_fail("getpeername"); printf("getpeername(%d, {sa_family=AF_UNIX" - ", sun_path=\"%s\"}, [%u]) = 0\n", - connect_fd, connect_inode, av[1], (unsigned) *len); + ", sun_path=\"%s\"}, [%d->%d]) = 0\n", + connect_fd, connect_inode, av[1], + (int) sizeof(addr), (int) *len); memset(accept_sa, 0, sizeof(addr)); *len = sizeof(addr); if (getsockname(connect_fd, accept_sa, len)) perror_msg_and_fail("getsockname"); printf("getsockname(%d, {sa_family=AF_UNIX" - ", sun_path=@\"%s\"}, [%u]) = 0\n", - connect_fd, connect_inode, sun_path1, (unsigned) *len); + ", sun_path=@\"%s\"}, [%d->%d]) = 0\n", + connect_fd, connect_inode, sun_path1, + (int) sizeof(addr), (int) *len); assert(sendto(connect_fd, text, sizeof(text) - 1, MSG_DONTWAIT, NULL, 0) == sizeof(text) - 1); diff --git a/tests/net-yy-unix.c b/tests/net-yy-unix.c index 7afdde1f..63637bdd 100644 --- a/tests/net-yy-unix.c +++ b/tests/net-yy-unix.c @@ -85,8 +85,8 @@ main(int ac, const char **av) if (getsockname(listen_fd, listen_sa, len)) perror_msg_and_fail("getsockname"); printf("getsockname(%d, {sa_family=AF_UNIX" - ", sun_path=\"%s\"}, [%u]) = 0\n", listen_fd, listen_inode, - av[1], av[1], (unsigned) *len); + ", sun_path=\"%s\"}, [%d->%d]) = 0\n", listen_fd, listen_inode, + av[1], av[1], (int) sizeof(addr), (int) *len); int connect_fd = socket(AF_UNIX, SOCK_STREAM, 0); if (connect_fd < 0) @@ -109,8 +109,8 @@ main(int ac, const char **av) perror_msg_and_fail("accept"); unsigned long accept_inode = inode_of_sockfd(accept_fd); printf("accept(%d, {sa_family=AF_UNIX}" - ", [%u]) = %d%lu,\"%s\"]>\n", - listen_fd, listen_inode, av[1], (unsigned) *len, + ", [%d->%d]) = %d%lu,\"%s\"]>\n", + listen_fd, listen_inode, av[1], (int) sizeof(addr), (int) *len, accept_fd, accept_inode, connect_inode, av[1]); memset(listen_sa, 0, sizeof(addr)); @@ -118,8 +118,9 @@ main(int ac, const char **av) if (getpeername(connect_fd, listen_sa, len)) perror_msg_and_fail("getpeername"); printf("getpeername(%d%lu]>, {sa_family=AF_UNIX" - ", sun_path=\"%s\"}, [%u]) = 0\n", connect_fd, connect_inode, - accept_inode, av[1], (unsigned) *len); + ", sun_path=\"%s\"}, [%d->%d]) = 0\n", + connect_fd, connect_inode, + accept_inode, av[1], (int) sizeof(addr), (int) *len); char text[] = "text"; assert(sendto(connect_fd, text, sizeof(text) - 1, MSG_DONTWAIT, NULL, 0) @@ -164,8 +165,8 @@ main(int ac, const char **av) if (getsockname(listen_fd, listen_sa, len)) perror_msg_and_fail("getsockname"); printf("getsockname(%d, {sa_family=AF_UNIX" - ", sun_path=\"%s\"}, [%u]) = 0\n", listen_fd, listen_inode, - av[1], av[1], (unsigned) *len); + ", sun_path=\"%s\"}, [%d->%d]) = 0\n", listen_fd, listen_inode, + av[1], av[1], (int) sizeof(addr), (int) *len); if (connect(connect_fd, listen_sa, *len)) perror_msg_and_fail("connect"); @@ -182,8 +183,9 @@ main(int ac, const char **av) const char * const sun_path1 = ((struct sockaddr_un *) accept_sa) -> sun_path + 1; printf("accept(%d, {sa_family=AF_UNIX" - ", sun_path=@\"%s\"}, [%u]) = %d%lu,\"%s\"]>\n", - listen_fd, listen_inode, av[1], sun_path1, (unsigned) *len, + ", sun_path=@\"%s\"}, [%d->%d]) = %d%lu,\"%s\"]>\n", + listen_fd, listen_inode, av[1], sun_path1, + (int) sizeof(addr), (int) *len, accept_fd, accept_inode, connect_inode, av[1]); memset(listen_sa, 0, sizeof(addr)); @@ -191,8 +193,8 @@ main(int ac, const char **av) if (getpeername(connect_fd, listen_sa, len)) perror_msg_and_fail("getpeername"); printf("getpeername(%d%lu,@\"%s\"]>, {sa_family=AF_UNIX" - ", sun_path=\"%s\"}, [%u]) = 0\n", connect_fd, connect_inode, - accept_inode, sun_path1, av[1], (unsigned) *len); + ", sun_path=\"%s\"}, [%d->%d]) = 0\n", connect_fd, connect_inode, + accept_inode, sun_path1, av[1], (int) sizeof(addr), (int) *len); assert(sendto(connect_fd, text, sizeof(text) - 1, MSG_DONTWAIT, NULL, 0) == sizeof(text) - 1); diff --git a/tests/net.expected b/tests/net.expected index 51d64a89..80dd0701 100644 --- a/tests/net.expected +++ b/tests/net.expected @@ -3,5 +3,5 @@ [1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +bind\(0, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="net-local-stream"\}, 19\) += 0 [1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +listen\(0, 5\) += 0 [1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +getsockname\(0, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="net-local-stream"\}, \[19\]\) += 0 -[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +accept\(0, \{sa_family=AF_(LOCAL|UNIX|FILE)\}, \[2\]\) += 1 +[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +accept\(0, \{sa_family=AF_(LOCAL|UNIX|FILE)\}, \[19->2\]\) += 1 [1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +connect\(1, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="net-local-stream"\}, 19\) += 0