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/e723c86e473d
branches:  trunk
changeset: 369791:e723c86e473d
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu Sep 01 10:10:20 2022 +0000

description:
KNF. No functional change.

diffstat:

 usr.bin/netstat/atalk.c      |   40 ++++---
 usr.bin/netstat/bpf.c        |   48 ++++----
 usr.bin/netstat/fast_ipsec.c |  230 +++++++++++++++++++++++-------------------
 usr.bin/netstat/if.c         |   54 +++++-----
 usr.bin/netstat/inet.c       |   82 +++++++-------
 usr.bin/netstat/inet6.c      |  223 +++++++++++++++++++++--------------------
 usr.bin/netstat/main.c       |   39 +++---
 usr.bin/netstat/mbuf.c       |   22 ++--
 usr.bin/netstat/mroute.c     |   33 +++--
 usr.bin/netstat/mroute6.c    |   16 +-
 usr.bin/netstat/netstat.h    |   10 +-
 usr.bin/netstat/pfkey.c      |   10 +-
 usr.bin/netstat/pfsync.c     |    8 +-
 usr.bin/netstat/route.c      |   33 +++--
 usr.bin/netstat/unix.c       |   31 ++--
 usr.bin/netstat/vtw.c        |   33 ++---
 16 files changed, 476 insertions(+), 436 deletions(-)

diffs (truncated from 2323 to 300 lines):

diff -r 7dead46a8d42 -r e723c86e473d usr.bin/netstat/atalk.c
--- a/usr.bin/netstat/atalk.c   Thu Sep 01 09:37:06 2022 +0000
+++ b/usr.bin/netstat/atalk.c   Thu Sep 01 10:10:20 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atalk.c,v 1.19 2020/08/28 07:23:48 ozaki-r Exp $       */
+/*     $NetBSD: atalk.c,v 1.20 2022/09/01 10:10:20 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.19 2020/08/28 07:23:48 ozaki-r Exp $");
+__RCSID("$NetBSD: atalk.c,v 1.20 2022/09/01 10:10:20 msaitoh Exp $");
 #endif
 #endif /* not lint */
 
@@ -82,11 +82,12 @@
                case 0xffff:
                        return "????";
                case ATADDR_ANYNET:
-                       return ("*");
+                       return "*";
                }
        }
-       (void)snprintf(mybuf, sizeof(mybuf), "%hu", ntohs(sat->sat_addr.s_net));
-       return (mybuf);
+       (void)snprintf(mybuf, sizeof(mybuf), "%hu",
+           ntohs(sat->sat_addr.s_net));
+       return mybuf;
 }
 
 static const char *
@@ -99,12 +100,12 @@
                case ATADDR_BCAST:
                        return "bcast";
                case ATADDR_ANYNODE:
-                       return ("*");
+                       return "*";
                }
        }
-       (void)snprintf(mybuf, sizeof(mybuf), "%d", 
+       (void)snprintf(mybuf, sizeof(mybuf), "%d",
            (unsigned int)sat->sat_addr.s_node);
-       return (mybuf);
+       return mybuf;
 }
 
 static const char *
@@ -114,13 +115,13 @@
 
        switch (sat->sat_port) {
        case ATADDR_ANYPORT:
-               return ("*");
+               return "*";
        case 0xff:
                return "????";
        default:
                (void)snprintf(mybuf, sizeof(mybuf), "%d",
                    (unsigned int)sat->sat_port);
-               return (mybuf);
+               return mybuf;
        }
 }
 
@@ -138,7 +139,7 @@
                (void)snprintf(mybuf, sizeof(mybuf), "%d",
                        ntohs(sat->sat_range.r_netrange.nr_firstnet));
        }
-       return (mybuf);
+       return mybuf;
 }
 
 
@@ -180,7 +181,7 @@
                (void)snprintf(mybuf + strlen(mybuf),
                    sizeof(mybuf) - strlen(mybuf), ".%s", at_pr_port(sat));
        }
-       return (mybuf);
+       return mybuf;
 }
 
 const char *
@@ -221,7 +222,7 @@
                if (l > 0)
                        n += l;
        }
-       return (buf);
+       return buf;
 }
 
 void
@@ -261,7 +262,7 @@
                        }
                        printf("%-5.5s %-6.6s %-6.6s  %*.*s %*.*s %s\n",
                               "Proto", "Recv-Q", "Send-Q",
-                              -width, width, "Local Address", 
+                              -width, width, "Local Address",
                               -width, width, "Foreign Address", "(state)");
                        first = 0;
                }
@@ -276,8 +277,9 @@
                putchar('\n');
        }
 }
-#define ANY(x,y,z) \
-       ((sflag==1 || (x)) ? printf("\t%llu %s%s%s\n",(unsigned long long)x,y,plural(x),z) : 0)
+#define ANY(x,y,z)                                                           \
+       ((sflag==1 || (x)) ?                                                  \
+           printf("\t%llu %s%s%s\n",(unsigned long long)x,y,plural(x),z) : 0)
 
 /*
  * Dump DDP statistics structure.
@@ -308,7 +310,9 @@
        ANY(ddpstat[DDP_STAT_TOOSMALL], "packet", " with not enough data ");
        ANY(ddpstat[DDP_STAT_FORWARD], "packet", " forwarded ");
        ANY(ddpstat[DDP_STAT_ENCAP], "packet", " encapsulated ");
-       ANY(ddpstat[DDP_STAT_CANTFORWARD], "packet", " rcvd for unreachable dest ");
-       ANY(ddpstat[DDP_STAT_NOSOCKSPACE], "packet", " dropped due to no socket space ");
+       ANY(ddpstat[DDP_STAT_CANTFORWARD], "packet",
+           " rcvd for unreachable dest ");
+       ANY(ddpstat[DDP_STAT_NOSOCKSPACE], "packet",
+           " dropped due to no socket space ");
 }
 #undef ANY
diff -r 7dead46a8d42 -r e723c86e473d usr.bin/netstat/bpf.c
--- a/usr.bin/netstat/bpf.c     Thu Sep 01 09:37:06 2022 +0000
+++ b/usr.bin/netstat/bpf.c     Thu Sep 01 10:10:20 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bpf.c,v 1.15 2020/08/28 07:23:48 ozaki-r Exp $ */
+/*     $NetBSD: bpf.c,v 1.16 2022/09/01 10:10:20 msaitoh Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -53,20 +53,19 @@
        size_t len = sizeof(bpf_s);
 
        if (use_sysctl) {
-               if (prog_sysctlbyname("net.bpf.stats", &bpf_s, &len, NULL, 0) == -1 &&
-                   errno != ENOMEM)
+               if (prog_sysctlbyname("net.bpf.stats", &bpf_s, &len, NULL, 0)
+                   == -1 && errno != ENOMEM)
                        err(1, "net.bpf.stats");
-       
+
                printf("bpf:\n");
-               printf("\t%" PRIu64 " total packets received\n", 
+               printf("\t%" PRIu64 " total packets received\n",
                    bpf_s.bs_recv);
-               printf("\t%" PRIu64 " total packets captured\n", 
+               printf("\t%" PRIu64 " total packets captured\n",
                    bpf_s.bs_capt);
-               printf("\t%" PRIu64 " total packets dropped\n", 
+               printf("\t%" PRIu64 " total packets dropped\n",
                    bpf_s.bs_drop);
-       } else {
+       } else
                warnx("BPF stats not available via KVM.");
-       }
 }
 
 void
@@ -80,7 +79,7 @@
                u_int   namelen;
                void    *v;
                struct kinfo_proc2 p;
-       
+
                /* adapted from sockstat.c by Andrew Brown */
 
                sz = CTL_MAXNAME;
@@ -90,7 +89,7 @@
 
                name[namelen++] = sizeof(*dpe);
                name[namelen++] = INT_MAX;
-               
+
                v = NULL;
                sz = 0;
                do {
@@ -118,19 +117,19 @@
 #define BPFEXT(entry) dpe->entry
 
                for (i = 0; i < (sz / sizeof(*dpe)); i++, dpe++) {
-                       if (bpfif && 
+                       if (bpfif &&
                            strncmp(BPFEXT(bde_ifname), bpfif, IFNAMSIZ))
                                continue;
-                       
+
                        printf("%-7d ", BPFEXT(bde_pid));
                        printf("%-7s ",
-                              (BPFEXT(bde_ifname)[0] == '\0') ? "-" : 
+                              (BPFEXT(bde_ifname)[0] == '\0') ? "-" :
                               BPFEXT(bde_ifname));
 
-                       printf("%-8" PRIu64 " %-8" PRIu64 " %-8" PRIu64 " ", 
-                               BPFEXT(bde_rcount), BPFEXT(bde_dcount), 
+                       printf("%-8" PRIu64 " %-8" PRIu64 " %-8" PRIu64 " ",
+                               BPFEXT(bde_rcount), BPFEXT(bde_dcount),
                                BPFEXT(bde_ccount));
-                       
+
                        switch (BPFEXT(bde_state)) {
                        case BPF_IDLE:
                                printf("I");
@@ -145,11 +144,12 @@
                                printf("-");
                                break;
                        }
-                       
+
                        printf("%c", BPFEXT(bde_promisc) ? 'P' : '-');
                        printf("%c", BPFEXT(bde_immediate) ? 'R' : '-');
-                       printf("%c", (BPFEXT(bde_direction) == BPF_D_IN) ? '-'
-                           : (BPFEXT(bde_direction) == BPF_D_OUT) ? 'O' : 'S');
+                       printf("%c", (BPFEXT(bde_direction) == BPF_D_IN) ?
+                           '-' : (BPFEXT(bde_direction) == BPF_D_OUT) ?
+                           'O' : 'S');
                        printf("%c", BPFEXT(bde_hdrcmplt) ? 'H' : '-');
                        printf("  %-8d ", BPFEXT(bde_bufsize));
 
@@ -162,7 +162,7 @@
                        name[namelen++] = szproc;
                        name[namelen++] = 1;
 
-                       if (prog_sysctl(&name[0], namelen, &p, &szproc, 
+                       if (prog_sysctl(&name[0], namelen, &p, &szproc,
                            NULL, 0) == -1)
                                printf("-\n");
                        else
@@ -171,7 +171,7 @@
                }
                free(v);
        } else {
-                /* XXX */
-                errx(1, "bpf_dump not implemented using kvm");
-        }
+               /* XXX */
+               errx(1, "bpf_dump not implemented using kvm");
+       }
 }
diff -r 7dead46a8d42 -r e723c86e473d usr.bin/netstat/fast_ipsec.c
--- a/usr.bin/netstat/fast_ipsec.c      Thu Sep 01 09:37:06 2022 +0000
+++ b/usr.bin/netstat/fast_ipsec.c      Thu Sep 01 10:10:20 2022 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: fast_ipsec.c,v 1.23 2019/08/18 04:14:40 kamil Exp $ */
-/*     $FreeBSD: src/tools/tools/crypto/ipsecstats.c,v 1.1.4.1 2003/06/03 00:13:13 sam Exp $ */
+/*     $NetBSD: fast_ipsec.c,v 1.24 2022/09/01 10:10:20 msaitoh Exp $ */
+/*     $FreeBSD: src/tools/tools/crypto/ipsecstats.c,v 1.1.4.1 2003/06/03 00:13:13 sam Exp $ */
 
 /*-
  * Copyright (c) 2003, 2004 Jonathan Stone
@@ -33,7 +33,7 @@
 #include <sys/cdefs.h>
 #ifndef lint
 #ifdef __NetBSD__
-__RCSID("$NetBSD: fast_ipsec.c,v 1.23 2019/08/18 04:14:40 kamil Exp $");
+__RCSID("$NetBSD: fast_ipsec.c,v 1.24 2022/09/01 10:10:20 msaitoh Exp $");
 #endif
 #endif /* not lint*/
 
@@ -89,7 +89,7 @@
 
 /*
  * Print the fast_ipsec statistics.
- * Since NetBSD's netstat(1) seems not to find us for "netstat -s", 
+ * Since NetBSD's netstat(1) seems not to find us for "netstat -s",
  * but does(?) find KAME, be prepared to be called explicitly from
  * netstat's main program for "netstat -s"; but silently do nothing
  * if that happens when we are running on KAME IPsec.
@@ -117,8 +117,8 @@
        memset(ipips, 0, sizeof(ipips));
 
        slen = sizeof(ipsecstats);
-       status = prog_sysctlbyname("net.inet.ipsec.ipsecstats", ipsecstats, &slen,
-                             NULL, 0);
+       status = prog_sysctlbyname("net.inet.ipsec.ipsecstats",
+           ipsecstats, &slen, NULL, 0);
        if (status < 0) {
                if (errno == ENOENT)
                        return;
@@ -127,146 +127,164 @@
        }
 
        slen = sizeof (ahstats);
-       status = prog_sysctlbyname("net.inet.ah.ah_stats", ahstats, &slen, NULL, 0);
+       status = prog_sysctlbyname("net.inet.ah.ah_stats",
+           ahstats, &slen, NULL, 0);
        if (status < 0 && errno != ENOMEM)
                err(1, "net.inet.ah.ah_stats");
 
        slen = sizeof (espstats);
-       status = prog_sysctlbyname("net.inet.esp.esp_stats", espstats, &slen, NULL, 0);
+       status = prog_sysctlbyname("net.inet.esp.esp_stats",
+           espstats, &slen, NULL, 0);
        if (status < 0 && errno != ENOMEM)
                err(1, "net.inet.esp.esp_stats");
 



Home | Main Index | Thread Index | Old Index