Source-Changes-HG archive

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

[src/trunk]: src/sys/net net/if_ppp.c: Sprinkle KNF. No functional change in...



details:   https://anonhg.NetBSD.org/src/rev/8f8b3be5a26e
branches:  trunk
changeset: 368351:8f8b3be5a26e
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Jul 06 08:06:59 2022 +0000

description:
net/if_ppp.c: Sprinkle KNF.  No functional change intended.

diffstat:

 sys/net/if_ppp.c |  140 +++++++++++++++++++++++++++++-------------------------
 1 files changed, 76 insertions(+), 64 deletions(-)

diffs (truncated from 397 to 300 lines):

diff -r e3177e0fe0e6 -r 8f8b3be5a26e sys/net/if_ppp.c
--- a/sys/net/if_ppp.c  Wed Jul 06 06:32:50 2022 +0000
+++ b/sys/net/if_ppp.c  Wed Jul 06 08:06:59 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ppp.c,v 1.167 2020/01/29 04:28:27 thorpej Exp $     */
+/*     $NetBSD: if_ppp.c,v 1.168 2022/07/06 08:06:59 riastradh Exp $   */
 /*     Id: if_ppp.c,v 1.6 1997/03/04 03:33:00 paulus Exp       */
 
 /*
@@ -102,7 +102,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.167 2020/01/29 04:28:27 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.168 2022/07/06 08:06:59 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "ppp.h"
@@ -323,7 +323,7 @@
        sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN;
        sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN;
        /* Ratio of 1:2 packets between the regular and the fast queue */
-       sc->sc_maxfastq = 2;    
+       sc->sc_maxfastq = 2;
        IFQ_SET_READY(&sc->sc_if.if_snd);
        if_attach(&sc->sc_if);
        if_alloc_sadl(&sc->sc_if);
@@ -384,7 +384,7 @@
        if (sc->sc_si == NULL) {
                printf("%s: unable to establish softintr\n",
                    sc->sc_if.if_xname);
-               return (NULL);
+               return NULL;
        }
        sc->sc_flags = 0;
        sc->sc_mru = PPP_MRU;
@@ -514,14 +514,14 @@
                if (kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE,
                        KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, &sc->sc_if,
                        KAUTH_ARG(cmd), NULL) != 0)
-                       return (EPERM);
+                       return EPERM;
                break;
        case PPPIOCXFERUNIT:
                /* XXX: Why is this privileged?! */
                if (kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE,
                        KAUTH_REQ_NETWORK_INTERFACE_GETPRIV, &sc->sc_if,
                        KAUTH_ARG(cmd), NULL) != 0)
-                       return (EPERM);
+                       return EPERM;
                break;
        default:
                break;
@@ -593,22 +593,22 @@
 
 #ifdef PPP_COMPRESS
        case PPPIOCSCOMPRESS:
-               odp = (struct ppp_option_data *) data;
+               odp = (struct ppp_option_data *)data;
                nb = odp->length;
                if (nb > sizeof(ccp_option))
                        nb = sizeof(ccp_option);
                if ((error = copyin(odp->ptr, ccp_option, nb)) != 0)
-                       return (error);
+                       return error;
                /* preliminary check on the length byte */
                if (ccp_option[1] < 2)
-                       return (EINVAL);
+                       return EINVAL;
                cp = ppp_get_compressor(ccp_option[0]);
                if (cp == NULL) {
                        if (sc->sc_flags & SC_DEBUG)
                                printf("%s: no compressor for [%x %x %x], %x\n",
                                    sc->sc_if.if_xname, ccp_option[0],
                                    ccp_option[1], ccp_option[2], nb);
-                       return (EINVAL);        /* no handler found */
+                       return EINVAL;  /* no handler found */
                }
                /*
                 * Found a handler for the protocol - try to allocate
@@ -650,12 +650,12 @@
                        sc->sc_flags &= ~SC_DECOMP_RUN;
                        splx(s);
                }
-               return (error);
+               return error;
 #endif /* PPP_COMPRESS */
 
        case PPPIOCGNPMODE:
        case PPPIOCSNPMODE:
-               npi = (struct npioctl *) data;
+               npi = (struct npioctl *)data;
                switch (npi->protocol) {
                case PPP_IP:
                        npx = NP_IP;
@@ -699,7 +699,7 @@
        case PPPIOCSOPASS:
        case PPPIOCSIACTIVE:
        case PPPIOCSOACTIVE:
-               nbp = (struct bpf_program *) data;
+               nbp = (struct bpf_program *)data;
                if ((unsigned) nbp->bf_len > BPF_MAXINSNS)
                        return EINVAL;
                newcodelen = nbp->bf_len * sizeof(struct bpf_insn);
@@ -735,7 +735,7 @@
                        break;
                default:
                        free(newcode, M_DEVBUF);
-                       return (EPASSTHROUGH);
+                       return EPASSTHROUGH;
                }
                oldcode = bp->bf_insns;
                s = splnet();
@@ -748,9 +748,9 @@
 #endif /* PPP_FILTER */
 
        default:
-               return (EPASSTHROUGH);
+               return EPASSTHROUGH;
        }
-       return (0);
+       return 0;
 }
 
 /*
@@ -817,7 +817,7 @@
                break;
 
        case SIOCGPPPSTATS:
-               psp = &((struct ifpppstatsreq *) data)->stats;
+               psp = &((struct ifpppstatsreq *)data)->stats;
                memset(psp, 0, sizeof(*psp));
                psp->p = sc->sc_stats;
 #if defined(VJC) && !defined(SL_NO_STATS)
@@ -836,7 +836,7 @@
 
 #ifdef PPP_COMPRESS
        case SIOCGPPPCSTATS:
-               pcp = &((struct ifpppcstatsreq *) data)->stats;
+               pcp = &((struct ifpppcstatsreq *)data)->stats;
                memset(pcp, 0, sizeof(*pcp));
                if (sc->sc_xc_state != NULL)
                        (*sc->sc_xcomp->comp_stat)(sc->sc_xc_state, &pcp->c);
@@ -851,7 +851,7 @@
                break;
        }
        splx(s);
-       return (error);
+       return error;
 }
 
 /*
@@ -873,8 +873,10 @@
        enum NPmode mode;
        int len;
 
-           if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0
-               || ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) {
+           if (sc->sc_devp == NULL ||
+               (ifp->if_flags & IFF_RUNNING) == 0 ||
+               ((ifp->if_flags & IFF_UP) == 0 &&
+                   dst->sa_family != AF_UNSPEC)) {
                    error = ENETDOWN;   /* sort of */
                    goto bad;
            }
@@ -973,8 +975,8 @@
                 * Apply the pass and active filters to the packet,
                 * but only if it is a data packet.
                 */
-               if (sc->sc_pass_filt_out.bf_insns != 0
-                   && bpf_filter(sc->sc_pass_filt_out.bf_insns,
+               if (sc->sc_pass_filt_out.bf_insns != 0 &&
+                   bpf_filter(sc->sc_pass_filt_out.bf_insns,
                        (u_char *)m0, len, 0) == 0) {
                        error = 0;              /* drop this packet */
                        goto bad;
@@ -983,8 +985,8 @@
                /*
                 * Update the time we sent the most recent packet.
                 */
-               if (sc->sc_active_filt_out.bf_insns == 0
-                   || bpf_filter(sc->sc_active_filt_out.bf_insns,
+               if (sc->sc_active_filt_out.bf_insns == 0 ||
+                   bpf_filter(sc->sc_active_filt_out.bf_insns,
                        (u_char *)m0, len, 0))
                        sc->sc_last_sent = time_second;
 #else
@@ -1015,18 +1017,18 @@
                        splx(s);
                        if_statinc(&sc->sc_if, if_oerrors);
                        sc->sc_stats.ppp_oerrors++;
-                       return (error);
+                       return error;
                }
                ppp_restart(sc);
        }
        if_statadd2(ifp, if_opackets, 1, if_obytes, len);
 
        splx(s);
-       return (0);
+       return 0;
 
 bad:
        m_freem(m0);
-       return (error);
+       return error;
 }
 
 /*
@@ -1158,7 +1160,7 @@
                        int type;
 
                        mp = m;
-                       ip = (struct ip *) (cp + PPP_HDRLEN);
+                       ip = (struct ip *)(cp + PPP_HDRLEN);
                        if (mp->m_len <= PPP_HDRLEN) {
                                mp = mp->m_next;
                                if (mp == NULL)
@@ -1199,8 +1201,8 @@
        }
 
 #ifdef PPP_COMPRESS
-       if (protocol != PPP_LCP && protocol != PPP_CCP
-           && sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN)) {
+       if (protocol != PPP_LCP && protocol != PPP_CCP &&
+           sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN)) {
                struct mbuf *mcomp = NULL;
                int slen;
 
@@ -1264,9 +1266,10 @@
        int s;
 
        mutex_enter(softnet_lock);
-       if (!(sc->sc_flags & SC_TBUSY)
-           && (IFQ_IS_EMPTY(&sc->sc_if.if_snd) == 0 || sc->sc_fastq.ifq_head
-               || sc->sc_outm)) {
+       if (!(sc->sc_flags & SC_TBUSY) &&
+           (IFQ_IS_EMPTY(&sc->sc_if.if_snd) == 0 ||
+               sc->sc_fastq.ifq_head ||
+               sc->sc_outm)) {
                s = splhigh();  /* XXX IMP ME HARDER */
                sc->sc_flags |= SC_TBUSY;
                splx(s);
@@ -1332,15 +1335,16 @@
                break;
 
        case CCP_CONFACK:
-               if (sc->sc_flags & SC_CCP_OPEN && !(sc->sc_flags & SC_CCP_UP)
-                   && slen >= CCP_HDRLEN + CCP_OPT_MINLEN
-                   && slen >= CCP_OPT_LENGTH(dp + CCP_HDRLEN) + CCP_HDRLEN) {
+               if (sc->sc_flags & SC_CCP_OPEN &&
+                   !(sc->sc_flags & SC_CCP_UP) &&
+                   slen >= CCP_HDRLEN + CCP_OPT_MINLEN &&
+                   slen >= CCP_OPT_LENGTH(dp + CCP_HDRLEN) + CCP_HDRLEN) {
                        if (!rcvd) {
                                /* We're agreeing to send compressed packets. */
-                               if (sc->sc_xc_state != NULL
-                                   && (*sc->sc_xcomp->comp_init)
-                                   (sc->sc_xc_state, dp + CCP_HDRLEN,
-                                       slen - CCP_HDRLEN, sc->sc_unit, 0,
+                               if (sc->sc_xc_state != NULL &&
+                                   (*sc->sc_xcomp->comp_init)(sc->sc_xc_state,
+                                       dp + CCP_HDRLEN, slen - CCP_HDRLEN,
+                                       sc->sc_unit, 0,
                                        sc->sc_flags & SC_DEBUG)) {
                                        s = splhigh();  /* XXX IMP ME HARDER */
                                        sc->sc_flags |= SC_COMP_RUN;
@@ -1351,14 +1355,16 @@
                                 * Peer is agreeing to send compressed
                                 * packets.
                                 */
-                               if (sc->sc_rc_state != NULL
-                                   && (*sc->sc_rcomp->decomp_init)
-                                   (sc->sc_rc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN,
+                               if (sc->sc_rc_state != NULL &&
+                                   (*sc->sc_rcomp->decomp_init)(
+                                       sc->sc_rc_state,
+                                       dp + CCP_HDRLEN, slen - CCP_HDRLEN,
                                        sc->sc_unit, 0, sc->sc_mru,
                                        sc->sc_flags & SC_DEBUG)) {
                                        s = splhigh();  /* XXX IMP ME HARDER */
                                        sc->sc_flags |= SC_DECOMP_RUN;
-                                       sc->sc_flags &= ~(SC_DC_ERROR | SC_DC_FERROR);
+                                       sc->sc_flags &=
+                                           ~(SC_DC_ERROR | SC_DC_FERROR);
                                        splx(s);
                                }
                        }
@@ -1424,8 +1430,9 @@
  * Process a received PPP packet, doing decompression as necessary.
  * Should be called at splsoftnet.
  */
-#define COMPTYPE(proto)        ((proto) == PPP_VJC_COMP ? TYPE_COMPRESSED_TCP:       \
-           TYPE_UNCOMPRESSED_TCP)
+#define COMPTYPE(proto)                                                              \
+       ((proto) == PPP_VJC_COMP ? TYPE_COMPRESSED_TCP                        \
+           : TYPE_UNCOMPRESSED_TCP)
 
 static void
 ppp_inproc(struct ppp_softc *sc, struct mbuf *m)



Home | Main Index | Thread Index | Old Index