Source-Changes-HG archive

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

[src/trunk]: src/sys/net KNF. No functional change.



details:   https://anonhg.NetBSD.org/src/rev/6bf49ae9fd0d
branches:  trunk
changeset: 372421:6bf49ae9fd0d
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Fri Nov 25 06:18:42 2022 +0000

description:
KNF. No functional change.

diffstat:

 sys/net/if.c |  101 ++++++++++++++++++++++++++++++++--------------------------
 1 files changed, 56 insertions(+), 45 deletions(-)

diffs (truncated from 369 to 300 lines):

diff -r 83797ec4fbf7 -r 6bf49ae9fd0d sys/net/if.c
--- a/sys/net/if.c      Thu Nov 24 21:07:05 2022 +0000
+++ b/sys/net/if.c      Fri Nov 25 06:18:42 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.527 2022/10/24 08:11:25 msaitoh Exp $ */
+/*     $NetBSD: if.c,v 1.528 2022/11/25 06:18:42 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.527 2022/10/24 08:11:25 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.528 2022/11/25 06:18:42 msaitoh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -367,18 +367,21 @@
 ifnet_t *
 if_alloc(u_char type)
 {
+
        return kmem_zalloc(sizeof(ifnet_t), KM_SLEEP);
 }
 
 void
 if_free(ifnet_t *ifp)
 {
+
        kmem_free(ifp, sizeof(ifnet_t));
 }
 
 void
 if_initname(struct ifnet *ifp, const char *name, int unit)
 {
+
        (void)snprintf(ifp->if_xname, sizeof(ifp->if_xname),
            "%s%d", name, unit);
 }
@@ -483,7 +486,8 @@
 
        namelen = strlen(ifp->if_xname);
        addrlen = ifp->if_addrlen;
-       socksize = roundup(sockaddr_dl_measure(namelen, addrlen), sizeof(long));
+       socksize = roundup(sockaddr_dl_measure(namelen, addrlen),
+           sizeof(long));
        ifasize = sizeof(*ifa) + 2 * socksize;
        ifa = malloc(ifasize, M_IFADDR, M_WAITOK | M_ZERO);
 
@@ -641,8 +645,7 @@
        char xnamebuf[HOOKNAMSIZ];
 
        ifp->if_index_gen = index_gen++;
-       snprintf(xnamebuf, sizeof(xnamebuf),
-           "%s-lshk", ifp->if_xname);
+       snprintf(xnamebuf, sizeof(xnamebuf), "%s-lshk", ifp->if_xname);
        ifp->if_linkstate_hooks = simplehook_create(IPL_NET,
            xnamebuf);
 
@@ -669,9 +672,8 @@
                         * slot in ifindex2ifnet[], then there
                         * there are too many (>65535) interfaces.
                         */
-                       if (hitlimit) {
+                       if (hitlimit)
                                panic("too many interfaces");
-                       }
                        hitlimit = true;
                        if_index = 1;
                }
@@ -1064,8 +1066,9 @@
 {
 
        return ALTQ_IS_ENABLED(&ifp->if_snd) ||
-               ifp->if_transmit == if_transmit ||
-               ifp->if_transmit == NULL || ifp->if_transmit == if_nulltransmit;
+           ifp->if_transmit == if_transmit ||
+           ifp->if_transmit == NULL ||
+           ifp->if_transmit == if_nulltransmit;
 }
 
 /*
@@ -1224,7 +1227,8 @@
 }
 
 void
-if_purgeaddrs(struct ifnet *ifp, int family, void (*purgeaddr)(struct ifaddr *))
+if_purgeaddrs(struct ifnet *ifp, int family,
+    void (*purgeaddr)(struct ifaddr *))
 {
        struct ifaddr *ifa, *nifa;
        int s;
@@ -1504,7 +1508,8 @@
                 * addresses.  (Protocols which might store ifnet
                 * pointers are marked with PR_PURGEIF.)
                 */
-               for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) {
+               for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
+               {
                        so.so_proto = pr;
                        if (pr->pr_usrreqs && pr->pr_flags & PR_PURGEIF)
                                (void)(*pr->pr_usrreqs->pr_purgeif)(&so, ifp);
@@ -1567,9 +1572,9 @@
 if_clone_create(const char *name)
 {
        struct if_clone *ifc;
-       int unit;
        struct ifnet *ifp;
        struct psref psref;
+       int unit;
 
        KASSERT(mutex_owned(&if_clone_mtx));
 
@@ -1753,8 +1758,7 @@
                goto out;
        }
 
-       count = (if_cloners_count < buf_count) ?
-           if_cloners_count : buf_count;
+       count = (if_cloners_count < buf_count) ? if_cloners_count : buf_count;
 
        for (ifc = LIST_FIRST(&if_cloners); ifc != NULL && count != 0;
             ifc = LIST_NEXT(ifc, ifc_list), count--, dst += IFNAMSIZ) {
@@ -1844,7 +1848,8 @@
         * if_is_deactivated indicates ifa_remove is called from if_detach
         * where it is safe even if IFNET_LOCK isn't held.
         */
-       KASSERT(!if_is_mpsafe(ifp) || if_is_deactivated(ifp) || IFNET_LOCKED(ifp));
+       KASSERT(!if_is_mpsafe(ifp) || if_is_deactivated(ifp) ||
+           IFNET_LOCKED(ifp));
 
        TAILQ_REMOVE(&ifp->if_addrlist, ifa, ifa_list);
        IFADDR_WRITER_REMOVE(ifa);
@@ -1889,6 +1894,7 @@
 static inline int
 equal(const struct sockaddr *sa1, const struct sockaddr *sa2)
 {
+
        return sockaddr_cmp(sa1, sa2) == 0;
 }
 
@@ -2005,7 +2011,8 @@
                IFNET_READER_FOREACH(ifp) {
                        if (if_is_deactivated(ifp))
                                continue;
-                       ifa = at_ifawithnet((const struct sockaddr_at *)addr, ifp);
+                       ifa = at_ifawithnet((const struct sockaddr_at *)addr,
+                           ifp);
                        if (ifa == NULL)
                                continue;
                        sat2 = (struct sockaddr_at *)ifa->ifa_addr;
@@ -2041,7 +2048,7 @@
                        }
                        if (ifa_maybe == NULL ||
                            rt_refines(ifa->ifa_netmask,
-                                      ifa_maybe->ifa_netmask))
+                                      ifa_maybe->ifa_netmask))
                                ifa_maybe = ifa;
                }
        }
@@ -2272,11 +2279,13 @@
                 * detached and the queue is being drained so we need
                 * to avoid queuing more work.
                 */
-                if (ifp->if_link_state == link_state || ifp->if_link_scheduled)
+                if (ifp->if_link_state == link_state ||
+                    ifp->if_link_scheduled)
                        goto out;
        } else {
                /* Ensure link_state doesn't match the last queued state. */
-               if (LQ_ITEM(ifp->if_link_queue, idx - 1) == (uint8_t)link_state)
+               if (LQ_ITEM(ifp->if_link_queue, idx - 1)
+                   == (uint8_t)link_state)
                        goto out;
        }
 
@@ -2415,7 +2424,8 @@
        IF_LINK_STATE_CHANGE_LOCK(ifp);
        if (LQ_ITEM(ifp->if_link_queue, 0) != LINK_STATE_UNSET) {
                ifp->if_link_scheduled = true;
-               workqueue_enqueue(ifnet_link_state_wq, &ifp->if_link_work, NULL);
+               workqueue_enqueue(ifnet_link_state_wq, &ifp->if_link_work,
+                   NULL);
        } else
                ifp->if_link_scheduled = false;
        IF_LINK_STATE_CHANGE_UNLOCK(ifp);
@@ -2436,7 +2446,8 @@
 }
 
 void
-if_linkstate_change_disestablish(struct ifnet *ifp, void *vhook, kmutex_t *lock)
+if_linkstate_change_disestablish(struct ifnet *ifp, void *vhook,
+    kmutex_t *lock)
 {
 
        simplehook_disestablish(ifp->if_linkstate_hooks, vhook, lock);
@@ -2627,6 +2638,7 @@
 {
        bool fire = false;
        const int s = splnet();
+
        KERNEL_LOCK(1, NULL);
        if (ifp->if_timer != 0 && --ifp->if_timer == 0)
                fire = true;
@@ -2650,9 +2662,8 @@
                                workqueue_enqueue(if_slowtimo_wq,
                                    &isd->isd_work, NULL);
                        }
-               } else {
+               } else
                        callout_schedule(&isd->isd_ch, hz / IFNET_SLOWHZ);
-               }
        }
        mutex_exit(&isd->isd_lock);
 }
@@ -2664,6 +2675,7 @@
            container_of(work, struct if_slowtimo_data, isd_work);
        struct ifnet *ifp = isd->isd_ifp;
        const int s = splnet();
+
        KERNEL_LOCK(1, NULL);
        (*ifp->if_slowtimo)(ifp);
        KERNEL_UNLOCK_ONE(NULL);
@@ -2786,9 +2798,9 @@
        }
        ret = if_flags_set(ifp, nflags);
        /* Restore interface state if not successful. */
-       if (ret != 0) {
+       if (ret != 0)
                ifp->if_pcount = pcount;
-       }
+
 out:
        return ret;
 }
@@ -2887,9 +2899,8 @@
        /*
         * If the entire name is a number, treat it as an ifindex.
         */
-       for (i = 0; i < IFNAMSIZ && *cp >= '0' && *cp <= '9'; i++, cp++) {
+       for (i = 0; i < IFNAMSIZ && *cp >= '0' && *cp <= '9'; i++, cp++)
                unit = unit * 10 + (*cp - '0');
-       }
 
        /*
         * If the number took all of the name, then it's a valid ifindex.
@@ -2902,7 +2913,7 @@
        IFNET_READER_FOREACH(ifp) {
                if (if_is_deactivated(ifp))
                        continue;
-               if (strcmp(ifp->if_xname, name) == 0)
+               if (strcmp(ifp->if_xname, name) == 0)
                        goto out;
        }
 out:
@@ -2926,9 +2937,8 @@
        /*
         * If the entire name is a number, treat it as an ifindex.
         */
-       for (i = 0; i < IFNAMSIZ && *cp >= '0' && *cp <= '9'; i++, cp++) {
+       for (i = 0; i < IFNAMSIZ && *cp >= '0' && *cp <= '9'; i++, cp++)
                unit = unit * 10 + (*cp - '0');
-       }
 
        /*
         * If the number took all of the name, then it's a valid ifindex.
@@ -3057,8 +3067,8 @@
 }
 
 /*
- * Some tunnel interfaces can nest, e.g. IPv4 over IPv4 gif(4) tunnel over IPv4.
- * Check the tunnel nesting count.
+ * Some tunnel interfaces can nest, e.g. IPv4 over IPv4 gif(4) tunnel over
+ * IPv4. Check the tunnel nesting count.
  * Return > 0, if tunnel nesting count is more than limit.
  * Return 0, if tunnel nesting count is equal or less than limit.
  */
@@ -3085,8 +3095,8 @@
                        count = (int *)(mtag + 1);
                        *count = 0;
                } else {
-                       log(LOG_DEBUG,
-                           "%s: m_tag_get() failed, recursion calls are not prevented.\n",
+                       log(LOG_DEBUG, "%s: m_tag_get() failed, "
+                           "recursion calls are not prevented.\n",
                            ifp->if_xname);
                }
        }
@@ -3131,7 +3141,8 @@
 
 
 static void
-if_tunnel_rtcache_free_pc(void *p, void *arg __unused, struct cpu_info *ci __unused)
+if_tunnel_rtcache_free_pc(void *p, void *arg __unused,
+    struct cpu_info *ci __unused)
 {
        struct tunnel_ro *tro = p;
 
@@ -3339,7 +3350,7 @@



Home | Main Index | Thread Index | Old Index