]> granicus.if.org Git - strace/commitdiff
Move fallback -yy socket print from printfd to print_sockaddr_by_inode
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 23 Jan 2016 16:35:02 +0000 (16:35 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 23 Jan 2016 16:35:02 +0000 (16:35 +0000)
* util.c (printfd): In -yy mode, move fallback print of proto:[inode] ...
* socketutils.c (to print_sockaddr_by_inode): ... here.

socketutils.c
util.c

index f0faf8ce24248b58e495e3bd9651ea5ad8b24a62..2f4a9b03c9f75edc994a3704b26c53905dd92b58 100644 (file)
@@ -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 01969a7f255eb7376e7bcdf0060437992efd79b9..4616920ab816b2a857a0ff8d0214cfc3139c9b6d 100644 (file)
--- 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);