Index: sys/kern/uipc_mbuf.c =================================================================== RCS file: /home/ncvs/src/sys/kern/uipc_mbuf.c,v retrieving revision 1.61 diff -u -r1.61 uipc_mbuf.c --- sys/kern/uipc_mbuf.c 2001/01/09 23:58:56 1.61 +++ sys/kern/uipc_mbuf.c 2001/01/12 04:42:33 @@ -115,9 +115,7 @@ * machdep.c - for now, there is no reason for this stuff to go there. */ static void -mbinit(dummy) - void *dummy; -{ +mbinit(void *dummy) { vm_offset_t maxaddr, mb_map_size; /* @@ -128,7 +126,7 @@ mb_map_size = roundup2(mb_map_size, PAGE_SIZE); mb_map = kmem_suballoc(kmem_map, (vm_offset_t *)&mbutl, &maxaddr, mb_map_size); - /* XXX: mb_map->system_map = 1; */ + mb_map->system_map = 1; /* XXX */ /* * Initialize the free list headers, and setup locks for lists. @@ -179,10 +177,7 @@ * Must be called with the mcntfree lock held. */ int -m_alloc_ref(nmb, how) - u_int nmb; - int how; -{ +m_alloc_ref(u_int nmb, int how) { caddr_t p; u_int nbytes; int i; @@ -209,8 +204,7 @@ if ((p = (caddr_t)kmem_malloc(mb_map, nbytes, how == M_TRYWAIT ? M_WAITOK : M_NOWAIT)) == NULL) { mtx_exit(&Giant, MTX_DEF); - mtx_enter(&mcntfree.m_mtx, MTX_DEF); /* XXX: We must be holding - it going out. */ + mtx_enter(&mcntfree.m_mtx, MTX_DEF); return (0); } mtx_exit(&Giant, MTX_DEF); @@ -238,12 +232,9 @@ * Must be called with the mmbfree lock held. */ int -m_mballoc(nmb, how) - register int nmb; - int how; -{ - register caddr_t p; - register int i; +m_mballoc(int nmb, int how) { + caddr_t p; + int i; int nbytes; /* @@ -269,7 +260,7 @@ mtx_exit(&mmbfree.m_mtx, MTX_DEF); mtx_enter(&Giant, MTX_DEF); p = (caddr_t)kmem_malloc(mb_map, nbytes, M_NOWAIT); - if (p == 0 && how == M_TRYWAIT) { + if (p == NULL && how == M_TRYWAIT) { atomic_add_long(&mbstat.m_wait, 1); p = (caddr_t)kmem_malloc(mb_map, nbytes, M_WAITOK); } @@ -312,8 +303,7 @@ * Must be called with the mmbfree mutex held. */ struct mbuf * -m_mballoc_wait(void) -{ +m_mballoc_wait(void) { struct mbuf *p = NULL; /* @@ -370,12 +360,9 @@ * Must be called with the mclfree lock held. */ int -m_clalloc(ncl, how) - register int ncl; - int how; -{ - register caddr_t p; - register int i; +m_clalloc(int ncl, int how) { + caddr_t p; + int i; int npg; /* @@ -428,8 +415,7 @@ * Must be called with the mclfree lock held. */ caddr_t -m_clalloc_wait(void) -{ +m_clalloc_wait(void) { caddr_t p = NULL; m_clalloc_wid++; @@ -462,10 +448,9 @@ * reverse order relative to one of the locks in the drain routines. */ static void -m_reclaim() -{ - register struct domain *dp; - register struct protosw *pr; +m_reclaim(void) { + struct domain *dp; + struct protosw *pr; for (dp = domains; dp; dp = dp->dom_next) for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) @@ -480,53 +465,43 @@ * for critical paths. */ struct mbuf * -m_get(how, type) - int how, type; -{ - register struct mbuf *m; +m_get(int how, int type) { + struct mbuf *m; MGET(m, how, type); return (m); } struct mbuf * -m_gethdr(how, type) - int how, type; -{ - register struct mbuf *m; +m_gethdr(int how, int type) { + struct mbuf *m; MGETHDR(m, how, type); return (m); } struct mbuf * -m_getclr(how, type) - int how, type; -{ - register struct mbuf *m; +m_getclr(int how, int type) { + struct mbuf *m; MGET(m, how, type); - if (m == 0) - return (0); + if (m == NULL) + return (NULL); bzero(mtod(m, caddr_t), MLEN); return (m); } struct mbuf * -m_free(m) - struct mbuf *m; -{ - register struct mbuf *n; +m_free(struct mbuf *m) { + struct mbuf *n; MFREE(m, n); return (n); } void -m_freem(m) - register struct mbuf *m; -{ - register struct mbuf *n; +m_freem(struct mbuf *m) { + struct mbuf *n; if (m == NULL) return; @@ -546,7 +521,7 @@ } /* - * Mbuffer utility routines. + * Mbuf utility routines. */ /* @@ -555,10 +530,7 @@ * copy junk along. */ struct mbuf * -m_prepend(m, len, how) - register struct mbuf *m; - int len, how; -{ +m_prepend(struct mbuf *m, int len, int how) { struct mbuf *mn; MGET(mn, how, m->m_type); @@ -588,13 +560,9 @@ #define MCFail (mbstat.m_mcfail) struct mbuf * -m_copym(m, off0, len, wait) - register struct mbuf *m; - int off0, wait; - register int len; -{ - register struct mbuf *n, **np; - register int off = off0; +m_copym(struct mbuf *m, int off0, int len, int wait) { + struct mbuf *n, **np; + int off = off0; struct mbuf *top; int copyhdr = 0; @@ -612,14 +580,14 @@ np = ⊤ top = 0; while (len > 0) { - if (m == 0) { + if (m == NULL) { KASSERT(len == M_COPYALL, ("m_copym, length > size of mbuf chain")); break; } MGET(n, wait, m->m_type); *np = n; - if (n == 0) + if (n == NULL) goto nospace; if (copyhdr) { M_COPY_PKTHDR(n, m); @@ -644,13 +612,13 @@ m = m->m_next; np = &n->m_next; } - if (top == 0) + if (top == NULL) atomic_add_long(&MCFail, 1); return (top); nospace: m_freem(top); atomic_add_long(&MCFail, 1); - return (0); + return (NULL); } /* @@ -660,10 +628,7 @@ * only their reference counts are incremented. */ struct mbuf * -m_copypacket(m, how) - struct mbuf *m; - int how; -{ +m_copypacket(struct mbuf *m, int how) { struct mbuf *top, *n, *o; MGET(n, how, m->m_type); @@ -707,7 +672,7 @@ nospace: m_freem(top); atomic_add_long(&MCFail, 1); - return 0; + return (NULL); } /* @@ -715,13 +680,8 @@ * continuing for "len" bytes, into the indicated buffer. */ void -m_copydata(m, off, len, cp) - register struct mbuf *m; - register int off; - register int len; - caddr_t cp; -{ - register unsigned count; +m_copydata(struct mbuf *m, int off, int len, caddr_t cp) { + unsigned count; KASSERT(off >= 0, ("m_copydata, negative off %d", off)); KASSERT(len >= 0, ("m_copydata, negative len %d", len)); @@ -749,16 +709,13 @@ * you need a writable copy of an mbuf chain. */ struct mbuf * -m_dup(m, how) - struct mbuf *m; - int how; -{ +m_dup(struct mbuf *m, int how) { struct mbuf **p, *top = NULL; int remain, moff, nsize; /* Sanity check */ if (m == NULL) - return (0); + return (NULL); KASSERT((m->m_flags & M_PKTHDR) != 0, ("%s: !PKTHDR", __FUNCTION__)); /* While there's more data, get a new mbuf, tack it on, and fill it */ @@ -814,7 +771,7 @@ nospace: m_freem(top); atomic_add_long(&MCFail, 1); - return (0); + return (NULL); } /* @@ -823,9 +780,8 @@ * Any m_pkthdr is not updated. */ void -m_cat(m, n) - register struct mbuf *m, *n; -{ +m_cat(struct mbuf *m, struct mbuf *n) { + while (m->m_next) m = m->m_next; while (n) { @@ -844,13 +800,10 @@ } void -m_adj(mp, req_len) - struct mbuf *mp; - int req_len; -{ - register int len = req_len; - register struct mbuf *m; - register int count; +m_adj(struct mbuf *mp, int req_len) { + int len = req_len; + struct mbuf *m; + int count; if ((m = mp) == NULL) return; @@ -928,12 +881,9 @@ #define MPFail (mbstat.m_mpfail) struct mbuf * -m_pullup(n, len) - register struct mbuf *n; - int len; -{ - register struct mbuf *m; - register int count; +m_pullup(struct mbuf *n, int len) { + struct mbuf *m; + int count; int space; /* @@ -952,7 +902,7 @@ if (len > MHLEN) goto bad; MGET(m, M_DONTWAIT, n->m_type); - if (m == 0) + if (m == NULL) goto bad; m->m_len = 0; if (n->m_flags & M_PKTHDR) { @@ -983,7 +933,7 @@ bad: m_freem(n); atomic_add_long(&MPFail, 1); - return (0); + return (NULL); } /* @@ -992,22 +942,19 @@ * attempts to restore the chain to its original state. */ struct mbuf * -m_split(m0, len0, wait) - register struct mbuf *m0; - int len0, wait; -{ - register struct mbuf *m, *n; +m_split(struct mbuf *m0, int len0, int wait) { + struct mbuf *m, *n; unsigned len = len0, remain; for (m = m0; m && len > m->m_len; m = m->m_next) len -= m->m_len; - if (m == 0) - return (0); + if (m == NULL) + return (NULL); remain = m->m_len - len; if (m0->m_flags & M_PKTHDR) { MGETHDR(n, wait, m0->m_type); - if (n == 0) - return (0); + if (n == NULL) + return (NULL); n->m_pkthdr.rcvif = m0->m_pkthdr.rcvif; n->m_pkthdr.len = m0->m_pkthdr.len - len0; m0->m_pkthdr.len = len0; @@ -1017,21 +964,21 @@ /* m can't be the lead packet */ MH_ALIGN(n, 0); n->m_next = m_split(m, len, wait); - if (n->m_next == 0) { + if (n->m_next == NULL) { (void) m_free(n); - return (0); + return (NULL); } else return (n); } else MH_ALIGN(n, remain); } else if (remain == 0) { n = m->m_next; - m->m_next = 0; + m->m_next = NULL; return (n); } else { MGET(n, wait, m->m_type); - if (n == 0) - return (0); + if (n == NULL) + return (NULL); M_ALIGN(n, remain); } extpacket: @@ -1047,23 +994,20 @@ n->m_len = remain; m->m_len = len; n->m_next = m->m_next; - m->m_next = 0; + m->m_next = NULL; return (n); } /* * Routine to copy from device local memory into mbufs. */ struct mbuf * -m_devget(buf, totlen, off0, ifp, copy) - char *buf; - int totlen, off0; - struct ifnet *ifp; - void (*copy) __P((char *from, caddr_t to, u_int len)); +m_devget(char *buf, int totlen, int off0, struct ifnet *ifp, + void (*copy) __P((char *from, caddr_t to, u_int len))) { - register struct mbuf *m; + struct mbuf *m; struct mbuf *top = 0, **mp = ⊤ - register int off = off0, len; - register char *cp; + int off = off0, len; + char *cp; char *epkt; cp = buf; @@ -1073,8 +1017,8 @@ totlen -= 2 * sizeof(u_short); } MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == 0) - return (0); + if (m == NULL) + return (NULL); m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = totlen; m->m_len = MHLEN; @@ -1082,9 +1026,9 @@ while (totlen > 0) { if (top) { MGET(m, M_DONTWAIT, MT_DATA); - if (m == 0) { + if (m == NULL) { m_freem(top); - return (0); + return (NULL); } m->m_len = MLEN; } @@ -1126,24 +1070,19 @@ * chain if necessary. */ void -m_copyback(m0, off, len, cp) - struct mbuf *m0; - register int off; - register int len; - caddr_t cp; -{ - register int mlen; - register struct mbuf *m = m0, *n; +m_copyback(struct mbuf *m0, int off, int len, caddr_t cp) { + int mlen; + struct mbuf *m = m0, *n; int totlen = 0; - if (m0 == 0) + if (m0 == NULL) return; while (off > (mlen = m->m_len)) { off -= mlen; totlen += mlen; - if (m->m_next == 0) { + if (m->m_next == NULL) { n = m_getclr(M_DONTWAIT, m->m_type); - if (n == 0) + if (n == NULL) goto out; n->m_len = min(MLEN, len + off); m->m_next = n; @@ -1160,9 +1099,9 @@ totlen += mlen; if (len == 0) break; - if (m->m_next == 0) { + if (m->m_next == NULL) { n = m_get(M_DONTWAIT, m->m_type); - if (n == 0) + if (n == NULL) break; n->m_len = min(MLEN, len); m->m_next = n; @@ -1174,8 +1113,7 @@ } void -m_print(const struct mbuf *m) -{ +m_print(const struct mbuf *m) { int len; const struct mbuf *m2;