From ea8b8e31528d3caca76c1437afe11e8d49244727 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Sat, 23 Jan 2016 16:35:02 +0000 Subject: [PATCH] Move fallback -yy socket print from printfd to print_sockaddr_by_inode * util.c (printfd): In -yy mode, move fallback print of proto:[inode] ... * socketutils.c (to print_sockaddr_by_inode): ... here. --- socketutils.c | 5 +++++ util.c | 12 ++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/socketutils.c b/socketutils.c index f0faf8ce..2f4a9b03 100644 --- a/socketutils.c +++ b/socketutils.c @@ -326,6 +326,11 @@ print_sockaddr_by_inode(const unsigned long inode, const char *proto_name) r = inet_print(fd, AF_INET6, IPPROTO_UDP, inode, "UDPv6"); else if (strcmp(proto_name, "UNIX") == 0) r = unix_print(fd, inode); + + if (!r) { + tprintf("%s:[%lu]", proto_name, inode); + r = true; + } } else { const struct { const int family; diff --git a/util.c b/util.c index 01969a7f..4616920a 100644 --- a/util.c +++ b/util.c @@ -512,18 +512,14 @@ printfd(struct tcb *tcp, int fd) if (show_fd_path > 1 && strncmp(path, socket_prefix, socket_prefix_len) == 0 && path[path_len - 1] == ']') { - unsigned long inodenr; + unsigned long inodenr = + strtoul(path + socket_prefix_len, NULL, 10); #define PROTO_NAME_LEN 32 char proto_buf[PROTO_NAME_LEN]; const char *proto = getfdproto(tcp, fd, proto_buf, PROTO_NAME_LEN); - inodenr = strtoul(path + socket_prefix_len, NULL, 10); - if (!print_sockaddr_by_inode(inodenr, proto)) { - if (proto) - tprintf("%s:[%lu]", proto, inodenr); - else - tprints(path); - } + if (!print_sockaddr_by_inode(inodenr, proto)) + tprints(path); } else { print_quoted_string(path, path_len, QUOTE_OMIT_LEADING_TRAILING_QUOTES); -- 2.40.0