strace 4.4 net.c:printsock() patch

John Hughes john at Calva.COM
Tue Sep 18 09:04:05 UTC 2001


> There is a stray "}" emitted for AF_INET address in net.c:printsock()
> - stray because one is emitted for all address families at the end of
> the function.

Yup, also it says "sin_family=" even when it's not an AF_INET address
and it prints the family twice if it doesn't know what's going on:

xbind(FP1_XPG4, 0, {sin_family=0xf /* AF_??? */, {sa_family=15,
sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = -1 ENOTSOCK (Socket operation
on non-socket)

(one too few "}"'s there!).

Also it prints one to many "{"'s for AF_IPX.

Here's the patch I've applied:

Index: net.c
===================================================================
RCS file: /cvsroot/strace/strace/net.c,v
retrieving revision 1.24
diff -u -r1.24 net.c
--- net.c       2001/07/10 13:48:44     1.24
+++ net.c       2001/09/18 15:51:11
@@ -613,7 +613,7 @@
                return;
        }

-       tprintf("{sin_family=");
+       tprintf("{sa_family=");
        printxval(addrfams, addrbuf.sa.sa_family, "AF_???");
        tprintf(", ");

@@ -628,7 +628,7 @@
                }
                break;
        case AF_INET:
-               tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")}",
+               tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")",
                        ntohs(addrbuf.sin.sin_port),
inet_ntoa(addrbuf.sin.sin_addr));
                break;
 #ifdef HAVE_INET_NTOP
@@ -663,7 +663,7 @@
        case AF_IPX:
                {
                        int i;
-                       tprintf("{sipx_port=htons(%u), ",
+                       tprintf("sipx_port=htons(%u), ",
                                        ntohs(addrbuf.sipx.sipx_port));
                        /* Yes, I know, this does not look too
                         * strace-ish, but otherwise the IPX
@@ -703,7 +703,7 @@
        AF_X25 AF_ROSE etc. still need to be done */

        default:
-               tprintf("{sa_family=%u, sa_data=", addrbuf.sa.sa_family);
+               tprintf("sa_data=");
                printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data,
                        sizeof addrbuf.sa.sa_data);
                break;





More information about the Strace-devel mailing list