Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/netstat KNF. No functional change.



details:   https://anonhg.NetBSD.org/src/rev/2b34376210ea
branches:  trunk
changeset: 369815:2b34376210ea
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Fri Sep 02 06:25:43 2022 +0000

description:
KNF. No functional change.

diffstat:

 usr.bin/netstat/atalk.c  |    7 +-
 usr.bin/netstat/if.c     |   24 +--
 usr.bin/netstat/inet.c   |  307 ++++++++++++++++++++++++++++------------------
 usr.bin/netstat/inet6.c  |  137 ++++++++++++--------
 usr.bin/netstat/main.c   |   13 +-
 usr.bin/netstat/pfkey.c  |   36 +++-
 usr.bin/netstat/pfsync.c |   46 ++++--
 usr.bin/netstat/route.c  |   24 +-
 usr.bin/netstat/unix.c   |    9 +-
 9 files changed, 359 insertions(+), 244 deletions(-)

diffs (truncated from 1140 to 300 lines):

diff -r 8d188992cb76 -r 2b34376210ea usr.bin/netstat/atalk.c
--- a/usr.bin/netstat/atalk.c   Fri Sep 02 06:01:38 2022 +0000
+++ b/usr.bin/netstat/atalk.c   Fri Sep 02 06:25:43 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atalk.c,v 1.20 2022/09/01 10:10:20 msaitoh Exp $       */
+/*     $NetBSD: atalk.c,v 1.21 2022/09/02 06:25:43 msaitoh Exp $       */
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from @(#)atalk.c       1.1 (Whistle) 6/6/96";
 #else
-__RCSID("$NetBSD: atalk.c,v 1.20 2022/09/01 10:10:20 msaitoh Exp $");
+__RCSID("$NetBSD: atalk.c,v 1.21 2022/09/02 06:25:43 msaitoh Exp $");
 #endif
 #endif /* not lint */
 
@@ -244,9 +244,8 @@
                        return;
                next = ddpcb.ddp_next;
 #if 0
-               if (!aflag && atalk_nullhost(ddpcb.ddp_lsat)) {
+               if (!aflag && atalk_nullhost(ddpcb.ddp_lsat))
                        continue;
-               }
 #endif
                if (kread((u_long)ddpcb.ddp_socket,
                          (char *)&sockb, sizeof(sockb)) < 0)
diff -r 8d188992cb76 -r 2b34376210ea usr.bin/netstat/if.c
--- a/usr.bin/netstat/if.c      Fri Sep 02 06:01:38 2022 +0000
+++ b/usr.bin/netstat/if.c      Fri Sep 02 06:25:43 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.98 2022/09/01 10:10:20 msaitoh Exp $  */
+/*     $NetBSD: if.c,v 1.99 2022/09/02 06:25:43 msaitoh Exp $  */
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from: @(#)if.c 8.2 (Berkeley) 2/21/94";
 #else
-__RCSID("$NetBSD: if.c,v 1.98 2022/09/01 10:10:20 msaitoh Exp $");
+__RCSID("$NetBSD: if.c,v 1.99 2022/09/02 06:25:43 msaitoh Exp $");
 #endif
 #endif /* not lint */
 
@@ -132,12 +132,10 @@
                return;
        }
 
-       if (use_sysctl) {
+       if (use_sysctl)
                intpr_sysctl();
-       } else {
+       else
                intpr_kvm(ifnetaddr, pfunc);
-       }
-
 }
 
 static void
@@ -214,9 +212,9 @@
                        get_rtaddrs(ifm->ifm_addrs, sa, rti_info);
 
                        sdl = (struct sockaddr_dl *)rti_info[RTAX_IFP];
-                       if (sdl == NULL || sdl->sdl_family != AF_LINK) {
+                       if (sdl == NULL || sdl->sdl_family != AF_LINK)
                                continue;
-                       }
+
                        bzero(name, sizeof(name));
                        if (sdl->sdl_nlen >= IFNAMSIZ)
                                memcpy(name, sdl->sdl_data, IFNAMSIZ - 1);
@@ -538,9 +536,8 @@
                                ia4_print(&inm.inm_addr);
                                multiaddr = (u_long)inm.inm_list.le_next;
                        }
-               } else {
+               } else
                        mc4_print(ifindex);
-               }
                break;
 #ifdef INET6
        case AF_INET6:
@@ -551,9 +548,9 @@
                        sin6->sin6_scope_id = 0;
 #endif
 
-               if (use_sysctl) {
+               if (use_sysctl)
                        netmask6 = (struct sockaddr_in6 *)rtinfo[RTAX_NETMASK];
-               } else {
+               else {
                        struct in6_ifaddr *ifaddr_in6 = (void *)rtinfo;
                        netmask6 = &ifaddr_in6->ia_prefixmask;
                }
@@ -590,9 +587,8 @@
                                ia6_print(&inm.in6m_addr);
                                multiaddr = (u_long)inm.in6m_entry.le_next;
                        }
-               } else {
+               } else
                        mc6_print(ifindex);
-               }
                break;
 #endif /*INET6*/
 #ifndef SMALL
diff -r 8d188992cb76 -r 2b34376210ea usr.bin/netstat/inet.c
--- a/usr.bin/netstat/inet.c    Fri Sep 02 06:01:38 2022 +0000
+++ b/usr.bin/netstat/inet.c    Fri Sep 02 06:25:43 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: inet.c,v 1.115 2022/09/01 10:10:20 msaitoh Exp $       */
+/*     $NetBSD: inet.c,v 1.116 2022/09/02 06:25:43 msaitoh Exp $       */
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from: @(#)inet.c       8.4 (Berkeley) 4/20/94";
 #else
-__RCSID("$NetBSD: inet.c,v 1.115 2022/09/01 10:10:20 msaitoh Exp $");
+__RCSID("$NetBSD: inet.c,v 1.116 2022/09/02 06:25:43 msaitoh Exp $");
 #endif
 #endif /* not lint */
 
@@ -365,8 +365,7 @@
                memcpy(&src, &pcblist[i].ki_s, sizeof(src));
                memcpy(&dst, &pcblist[i].ki_d, sizeof(dst));
 
-               if (!aflag &&
-                   inet_lnaof(dst.sin_addr) == INADDR_ANY)
+               if (!aflag && (inet_lnaof(dst.sin_addr) == INADDR_ANY))
                        continue;
 
                if (first) {
@@ -413,18 +412,18 @@
 
        printf ("%s:\n", name);
 
-#define        ps(f, m) if (tcpstat[f] || sflag <= 1) \
-    printf(m, tcpstat[f])
-#define        p(f, m) if (tcpstat[f] || sflag <= 1) \
-    printf(m, tcpstat[f], plural(tcpstat[f]))
-#define        p2(f1, f2, m) if (tcpstat[f1] || tcpstat[f2] || sflag <= 1) \
-    printf(m, tcpstat[f1], plural(tcpstat[f1]), \
-    tcpstat[f2], plural(tcpstat[f2]))
-#define        p2s(f1, f2, m) if (tcpstat[f1] || tcpstat[f2] || sflag <= 1) \
-    printf(m, tcpstat[f1], plural(tcpstat[f1]), \
-    tcpstat[f2])
-#define        p3(f, m) if (tcpstat[f] || sflag <= 1) \
-    printf(m, tcpstat[f], plurales(tcpstat[f]))
+#define        ps(f, m) if (tcpstat[f] || sflag <= 1)  \
+               printf(m, tcpstat[f])
+#define        p(f, m) if (tcpstat[f] || sflag <= 1)                   \
+               printf(m, tcpstat[f], plural(tcpstat[f]))
+#define        p2(f1, f2, m) if (tcpstat[f1] || tcpstat[f2] || sflag <= 1)     \
+               printf(m, tcpstat[f1], plural(tcpstat[f1]),             \
+                   tcpstat[f2], plural(tcpstat[f2]))
+#define        p2s(f1, f2, m) if (tcpstat[f1] || tcpstat[f2] || sflag <= 1)    \
+               printf(m, tcpstat[f1], plural(tcpstat[f1]),             \
+                   tcpstat[f2])
+#define        p3(f, m) if (tcpstat[f] || sflag <= 1)                  \
+               printf(m, tcpstat[f], plurales(tcpstat[f]))
 
        p(TCP_STAT_SNDTOTAL, "\t%" PRIu64 " packet%s sent\n");
        p2(TCP_STAT_SNDPACK,TCP_STAT_SNDBYTE,
@@ -441,69 +440,84 @@
            "\t\t%" PRIu64 " send attempt%s resulted in self-quench\n");
        p(TCP_STAT_RCVTOTAL, "\t%" PRIu64 " packet%s received\n");
        p2(TCP_STAT_RCVACKPACK, TCP_STAT_RCVACKBYTE,
-               "\t\t%" PRIu64 " ack%s (for %" PRIu64 " byte%s)\n");
+           "\t\t%" PRIu64 " ack%s (for %" PRIu64 " byte%s)\n");
        p(TCP_STAT_RCVDUPACK, "\t\t%" PRIu64 " duplicate ack%s\n");
        p(TCP_STAT_RCVACKTOOMUCH, "\t\t%" PRIu64 " ack%s for unsent data\n");
        p2(TCP_STAT_RCVPACK, TCP_STAT_RCVBYTE,
-               "\t\t%" PRIu64 " packet%s (%" PRIu64 " byte%s) received in-sequence\n");
+           "\t\t%" PRIu64 " packet%s (%" PRIu64 " byte%s) received in-sequence\n");
        p2(TCP_STAT_RCVDUPPACK, TCP_STAT_RCVDUPBYTE,
-               "\t\t%" PRIu64 " completely duplicate packet%s (%" PRIu64 " byte%s)\n");
+           "\t\t%" PRIu64 " completely duplicate packet%s (%" PRIu64 " byte%s)\n");
        p(TCP_STAT_PAWSDROP, "\t\t%" PRIu64 " old duplicate packet%s\n");
        p2(TCP_STAT_RCVPARTDUPPACK, TCP_STAT_RCVPARTDUPBYTE,
-               "\t\t%" PRIu64 " packet%s with some dup. data (%" PRIu64 " byte%s duped)\n");
+           "\t\t%" PRIu64 " packet%s with some dup. data (%" PRIu64 " byte%s duped)\n");
        p2(TCP_STAT_RCVOOPACK, TCP_STAT_RCVOOBYTE,
-               "\t\t%" PRIu64 " out-of-order packet%s (%" PRIu64 " byte%s)\n");
+           "\t\t%" PRIu64 " out-of-order packet%s (%" PRIu64 " byte%s)\n");
        p2(TCP_STAT_RCVPACKAFTERWIN, TCP_STAT_RCVBYTEAFTERWIN,
-               "\t\t%" PRIu64 " packet%s (%" PRIu64 " byte%s) of data after window\n");
+           "\t\t%" PRIu64 " packet%s (%" PRIu64 " byte%s) of data after window\n");
        p(TCP_STAT_RCVWINPROBE, "\t\t%" PRIu64 " window probe%s\n");
        p(TCP_STAT_RCVWINUPD, "\t\t%" PRIu64 " window update packet%s\n");
-       p(TCP_STAT_RCVAFTERCLOSE, "\t\t%" PRIu64 " packet%s received after close\n");
-       p(TCP_STAT_RCVBADSUM, "\t\t%" PRIu64 " discarded for bad checksum%s\n");
-       p(TCP_STAT_RCVBADOFF, "\t\t%" PRIu64 " discarded for bad header offset field%s\n");
-       ps(TCP_STAT_RCVSHORT, "\t\t%" PRIu64 " discarded because packet too short\n");
+       p(TCP_STAT_RCVAFTERCLOSE,
+           "\t\t%" PRIu64 " packet%s received after close\n");
+       p(TCP_STAT_RCVBADSUM,
+           "\t\t%" PRIu64 " discarded for bad checksum%s\n");
+       p(TCP_STAT_RCVBADOFF,
+           "\t\t%" PRIu64 " discarded for bad header offset field%s\n");
+       ps(TCP_STAT_RCVSHORT,
+           "\t\t%" PRIu64 " discarded because packet too short\n");
        p(TCP_STAT_CONNATTEMPT, "\t%" PRIu64 " connection request%s\n");
        p(TCP_STAT_ACCEPTS, "\t%" PRIu64 " connection accept%s\n");
        p(TCP_STAT_CONNECTS,
-               "\t%" PRIu64 " connection%s established (including accepts)\n");
+           "\t%" PRIu64 " connection%s established (including accepts)\n");
        p2(TCP_STAT_CLOSED, TCP_STAT_DROPS,
-               "\t%" PRIu64 " connection%s closed (including %" PRIu64 " drop%s)\n");
-       p(TCP_STAT_CONNDROPS, "\t%" PRIu64 " embryonic connection%s dropped\n");
+           "\t%" PRIu64 " connection%s closed (including %" PRIu64 " drop%s)\n");
+       p(TCP_STAT_CONNDROPS,
+           "\t%" PRIu64 " embryonic connection%s dropped\n");
        p(TCP_STAT_DELAYED_FREE, "\t%" PRIu64 " delayed free%s of tcpcb\n");
        p2(TCP_STAT_RTTUPDATED, TCP_STAT_SEGSTIMED,
-               "\t%" PRIu64 " segment%s updated rtt (of %" PRIu64 " attempt%s)\n");
+           "\t%" PRIu64 " segment%s updated rtt (of %" PRIu64 " attempt%s)\n");
        p(TCP_STAT_REXMTTIMEO, "\t%" PRIu64 " retransmit timeout%s\n");
        p(TCP_STAT_TIMEOUTDROP,
-               "\t\t%" PRIu64 " connection%s dropped by rexmit timeout\n");
+           "\t\t%" PRIu64 " connection%s dropped by rexmit timeout\n");
        p2(TCP_STAT_PERSISTTIMEO, TCP_STAT_PERSISTDROPS,
           "\t%" PRIu64 " persist timeout%s (resulting in %" PRIu64 " dropped "
                "connection%s)\n");
        p(TCP_STAT_KEEPTIMEO, "\t%" PRIu64 " keepalive timeout%s\n");
        p(TCP_STAT_KEEPPROBE, "\t\t%" PRIu64 " keepalive probe%s sent\n");
-       p(TCP_STAT_KEEPDROPS, "\t\t%" PRIu64 " connection%s dropped by keepalive\n");
+       p(TCP_STAT_KEEPDROPS,
+           "\t\t%" PRIu64 " connection%s dropped by keepalive\n");
        p(TCP_STAT_PREDACK, "\t%" PRIu64 " correct ACK header prediction%s\n");
-       p(TCP_STAT_PREDDAT, "\t%" PRIu64 " correct data packet header prediction%s\n");
+       p(TCP_STAT_PREDDAT,
+           "\t%" PRIu64 " correct data packet header prediction%s\n");
        p3(TCP_STAT_PCBHASHMISS, "\t%" PRIu64 " PCB hash miss%s\n");
        ps(TCP_STAT_NOPORT, "\t%" PRIu64 " dropped due to no socket\n");
-       p(TCP_STAT_CONNSDRAINED, "\t%" PRIu64 " connection%s drained due to memory "
-               "shortage\n");
-       p(TCP_STAT_PMTUBLACKHOLE, "\t%" PRIu64 " PMTUD blackhole%s detected\n");
+       p(TCP_STAT_CONNSDRAINED,
+           "\t%" PRIu64 " connection%s drained due to memory shortage\n");
+       p(TCP_STAT_PMTUBLACKHOLE,
+           "\t%" PRIu64 " PMTUD blackhole%s detected\n");
 
        p(TCP_STAT_BADSYN, "\t%" PRIu64 " bad connection attempt%s\n");
        ps(TCP_STAT_SC_ADDED, "\t%" PRIu64 " SYN cache entries added\n");
        p(TCP_STAT_SC_COLLISIONS, "\t\t%" PRIu64 " hash collision%s\n");
        ps(TCP_STAT_SC_COMPLETED, "\t\t%" PRIu64 " completed\n");
-       ps(TCP_STAT_SC_ABORTED, "\t\t%" PRIu64 " aborted (no space to build PCB)\n");
+       ps(TCP_STAT_SC_ABORTED,
+           "\t\t%" PRIu64 " aborted (no space to build PCB)\n");
        ps(TCP_STAT_SC_TIMED_OUT, "\t\t%" PRIu64 " timed out\n");
-       ps(TCP_STAT_SC_OVERFLOWED, "\t\t%" PRIu64 " dropped due to overflow\n");
-       ps(TCP_STAT_SC_BUCKETOVERFLOW, "\t\t%" PRIu64 " dropped due to bucket overflow\n");
+       ps(TCP_STAT_SC_OVERFLOWED,
+           "\t\t%" PRIu64 " dropped due to overflow\n");
+       ps(TCP_STAT_SC_BUCKETOVERFLOW,
+           "\t\t%" PRIu64 " dropped due to bucket overflow\n");
        ps(TCP_STAT_SC_RESET, "\t\t%" PRIu64 " dropped due to RST\n");
-       ps(TCP_STAT_SC_UNREACH, "\t\t%" PRIu64 " dropped due to ICMP unreachable\n");
-       ps(TCP_STAT_SC_DELAYED_FREE, "\t\t%" PRIu64 " delayed free of SYN cache "
-               "entries\n");
-       p(TCP_STAT_SC_RETRANSMITTED, "\t%" PRIu64 " SYN,ACK%s retransmitted\n");
-       p(TCP_STAT_SC_DUPESYN, "\t%" PRIu64 " duplicate SYN%s received for entries "
+       ps(TCP_STAT_SC_UNREACH,
+           "\t\t%" PRIu64 " dropped due to ICMP unreachable\n");
+       ps(TCP_STAT_SC_DELAYED_FREE,
+           "\t\t%" PRIu64 " delayed free of SYN cache entries\n");
+       p(TCP_STAT_SC_RETRANSMITTED,
+           "\t%" PRIu64 " SYN,ACK%s retransmitted\n");
+       p(TCP_STAT_SC_DUPESYN,
+           "\t%" PRIu64 " duplicate SYN%s received for entries "
                "already in the cache\n");
-       p(TCP_STAT_SC_DROPPED, "\t%" PRIu64 " SYN%s dropped (no route or no space)\n");
+       p(TCP_STAT_SC_DROPPED,
+           "\t%" PRIu64 " SYN%s dropped (no route or no space)\n");
        p(TCP_STAT_BADSIG, "\t%" PRIu64 " packet%s with bad signature\n");
        p(TCP_STAT_GOODSIG, "\t%" PRIu64 " packet%s with good signature\n");
 
@@ -540,21 +554,22 @@
 
        printf ("%s:\n", name);
 
-#define        ps(f, m) if (udpstat[f] || sflag <= 1) \
-    printf(m, udpstat[f])
-#define        p(f, m) if (udpstat[f] || sflag <= 1) \
-    printf(m, udpstat[f], plural(udpstat[f]))
-#define        p3(f, m) if (udpstat[f] || sflag <= 1) \
-    printf(m, udpstat[f], plurales(udpstat[f]))
+#define        ps(f, m) if (udpstat[f] || sflag <= 1)  \
+               printf(m, udpstat[f])
+#define        p(f, m) if (udpstat[f] || sflag <= 1)                   \
+               printf(m, udpstat[f], plural(udpstat[f]))
+#define        p3(f, m) if (udpstat[f] || sflag <= 1)                  \
+               printf(m, udpstat[f], plurales(udpstat[f]))
 
        p(UDP_STAT_IPACKETS, "\t%" PRIu64 " datagram%s received\n");
        ps(UDP_STAT_HDROPS, "\t%" PRIu64 " with incomplete header\n");



Home | Main Index | Thread Index | Old Index