]> granicus.if.org Git - strace/commitdiff
Unexport print_sockaddr_by_inode_cached
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 3 Jun 2017 17:52:24 +0000 (17:52 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 3 Jun 2017 17:52:24 +0000 (17:52 +0000)
Change print_sockaddr_by_inode to be the only function exposed,
hide print_sockaddr_by_inode_cached as a part of implementation.

* defs.h (print_sockaddr_by_inode_cached): Remove prototype.
(print_sockaddr_by_inode): Add struct tcb * and descriptor arguments.
* socketutils.c (print_sockaddr_by_inode_cached): Make static.
(print_sockaddr_by_inode): Rename to print_sockaddr_by_inode_uncached,
make static.
(print_sockaddr_by_inode): New function.
* util.c (printfd): Update to use new print_sockaddr_by_inode.

defs.h
socketutils.c
util.c

diff --git a/defs.h b/defs.h
index 3c8c5a763868a91da3f4661fc2e011c38822b26c..70ff07bcdba5bbeaad64654c9b6c741598faaff4 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -596,8 +596,7 @@ printpath(struct tcb *, kernel_ulong_t addr);
                (sizeof(long long) * 3 * 2 + sizeof("{tv_sec=-, tv_nsec=}"))
 extern void printfd(struct tcb *, int);
 extern void print_sockaddr(struct tcb *tcp, const void *, int);
-extern bool print_sockaddr_by_inode(const unsigned long, const enum sock_proto);
-extern bool print_sockaddr_by_inode_cached(const unsigned long);
+extern bool print_sockaddr_by_inode(struct tcb *, int fd, unsigned long inode);
 extern void print_dirfd(struct tcb *, int);
 
 extern int
index 534c56eb869cece74128073fe4c61fe5c3abbd40..984c41be25df6b5b088b3900fc8cd245f42d48f7 100644 (file)
@@ -68,7 +68,7 @@ cache_and_print_inode_details(const unsigned long inode, char *const details)
        return 1;
 }
 
-bool
+static bool
 print_sockaddr_by_inode_cached(const unsigned long inode)
 {
        const cache_entry *const e = &cache[inode & CACHE_MASK];
@@ -457,11 +457,9 @@ get_proto_by_name(const char *const name)
        return SOCK_PROTO_UNKNOWN;
 }
 
-/* Given an inode number of a socket, print out the details
- * of the ip address and port. */
-
-bool
-print_sockaddr_by_inode(const unsigned long inode, const enum sock_proto proto)
+static bool
+print_sockaddr_by_inode_uncached(const unsigned long inode,
+                                const enum sock_proto proto)
 {
        if ((unsigned int) proto >= ARRAY_SIZE(protocols) ||
            (proto != SOCK_PROTO_UNKNOWN && !protocols[proto].print))
@@ -493,3 +491,12 @@ print_sockaddr_by_inode(const unsigned long inode, const enum sock_proto proto)
        close(fd);
        return r;
 }
+
+/* Given an inode number of a socket, print out its protocol details.  */
+bool
+print_sockaddr_by_inode(struct tcb *const tcp, const int fd,
+                       const unsigned long inode)
+{
+       return print_sockaddr_by_inode_cached(inode) ? true :
+               print_sockaddr_by_inode_uncached(inode, getfdproto(tcp, fd));
+}
diff --git a/util.c b/util.c
index 50334b4f165d25111e5ee746fc6984344489d4eb..e33b0a95f29a612654f8e771bbc24b4f40956eeb 100644 (file)
--- a/util.c
+++ b/util.c
@@ -640,17 +640,12 @@ printfd(struct tcb *tcp, int fd)
                unsigned long inode;
 
                tprintf("%d<", fd);
-               if (show_fd_path > 1
-                   && (str = STR_STRIP_PREFIX(path, "socket:[")) != path
-                   && (len = strlen(str)) && str[len - 1] == ']'
-                   && (inode = strtoul(str, NULL, 10))) {
-                       if (!print_sockaddr_by_inode_cached(inode)) {
-                               const enum sock_proto proto =
-                                       getfdproto(tcp, fd);
-                               if (!print_sockaddr_by_inode(inode, proto))
-                                       tprints(path);
-                       }
-               } else {
+               if (show_fd_path <= 1
+                   || (str = STR_STRIP_PREFIX(path, "socket:[")) == path
+                   || !(len = strlen(str))
+                   || str[len - 1] != ']'
+                   || !(inode = strtoul(str, NULL, 10))
+                   || !print_sockaddr_by_inode(tcp, fd, inode)) {
                        print_quoted_string(path, strlen(path),
                                            QUOTE_OMIT_LEADING_TRAILING_QUOTES);
                }