diff options
author | phk <phk@FreeBSD.org> | 2002-09-18 19:44:14 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2002-09-18 19:44:14 +0000 |
commit | 63d87674c83d54fccca1aacdd2cb1c827796d834 (patch) | |
tree | 80e29b0b20f950540c3d00897b86679074fa456b | |
parent | 369ca07115f3e95429a31404e4fd6ffeddc8dc48 (diff) | |
download | FreeBSD-src-63d87674c83d54fccca1aacdd2cb1c827796d834.zip FreeBSD-src-63d87674c83d54fccca1aacdd2cb1c827796d834.tar.gz |
Use m_length() instead of home-rolled versions.
-rw-r--r-- | sys/kern/uipc_sockbuf.c | 31 | ||||
-rw-r--r-- | sys/kern/uipc_socket2.c | 31 | ||||
-rw-r--r-- | sys/net/if_ppp.c | 17 | ||||
-rw-r--r-- | sys/netns/idp_usrreq.c | 10 | ||||
-rw-r--r-- | sys/netns/spp_usrreq.c | 3 | ||||
-rw-r--r-- | sys/netsmb/smb_rq.c | 4 | ||||
-rw-r--r-- | sys/nfsclient/nfs_socket.c | 8 | ||||
-rw-r--r-- | sys/nfsserver/nfs_syscalls.c | 7 |
8 files changed, 30 insertions, 81 deletions
diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c index f062b2d..239c408 100644 --- a/sys/kern/uipc_sockbuf.c +++ b/sys/kern/uipc_sockbuf.c @@ -498,11 +498,11 @@ sbappend(sb, m) #ifdef SOCKBUF_DEBUG void sbcheck(sb) - register struct sockbuf *sb; + struct sockbuf *sb; { - register struct mbuf *m; - register struct mbuf *n = 0; - register u_long len = 0, mbcnt = 0; + struct mbuf *m; + struct mbuf *n = 0; + u_long len = 0, mbcnt = 0; for (m = sb->sb_mb; m; m = n) { n = m->m_nextpkt; @@ -610,22 +610,18 @@ sbinsertoob(sb, m0) */ int sbappendaddr(sb, asa, m0, control) - register struct sockbuf *sb; + struct sockbuf *sb; struct sockaddr *asa; struct mbuf *m0, *control; { - register struct mbuf *m, *n; + struct mbuf *m, *n; int space = asa->sa_len; if (m0 && (m0->m_flags & M_PKTHDR) == 0) panic("sbappendaddr"); if (m0) space += m0->m_pkthdr.len; - for (n = control; n; n = n->m_next) { - space += n->m_len; - if (n->m_next == 0) /* keep pointer to last control buf */ - break; - } + space += m_length(control, &n); if (space > sbspace(sb)) return (0); if (asa->sa_len > MLEN) @@ -657,19 +653,12 @@ sbappendcontrol(sb, m0, control) struct sockbuf *sb; struct mbuf *control, *m0; { - register struct mbuf *m, *n; - int space = 0; + struct mbuf *m, *n; + int space; if (control == 0) panic("sbappendcontrol"); - for (m = control; ; m = m->m_next) { - space += m->m_len; - if (m->m_next == 0) - break; - } - n = m; /* save pointer to last control buffer */ - for (m = m0; m; m = m->m_next) - space += m->m_len; + space = m_length(control, &n) + m_length(m0, NULL); if (space > sbspace(sb)) return (0); n->m_next = m0; /* concatenate data to control */ diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c index f062b2d..239c408 100644 --- a/sys/kern/uipc_socket2.c +++ b/sys/kern/uipc_socket2.c @@ -498,11 +498,11 @@ sbappend(sb, m) #ifdef SOCKBUF_DEBUG void sbcheck(sb) - register struct sockbuf *sb; + struct sockbuf *sb; { - register struct mbuf *m; - register struct mbuf *n = 0; - register u_long len = 0, mbcnt = 0; + struct mbuf *m; + struct mbuf *n = 0; + u_long len = 0, mbcnt = 0; for (m = sb->sb_mb; m; m = n) { n = m->m_nextpkt; @@ -610,22 +610,18 @@ sbinsertoob(sb, m0) */ int sbappendaddr(sb, asa, m0, control) - register struct sockbuf *sb; + struct sockbuf *sb; struct sockaddr *asa; struct mbuf *m0, *control; { - register struct mbuf *m, *n; + struct mbuf *m, *n; int space = asa->sa_len; if (m0 && (m0->m_flags & M_PKTHDR) == 0) panic("sbappendaddr"); if (m0) space += m0->m_pkthdr.len; - for (n = control; n; n = n->m_next) { - space += n->m_len; - if (n->m_next == 0) /* keep pointer to last control buf */ - break; - } + space += m_length(control, &n); if (space > sbspace(sb)) return (0); if (asa->sa_len > MLEN) @@ -657,19 +653,12 @@ sbappendcontrol(sb, m0, control) struct sockbuf *sb; struct mbuf *control, *m0; { - register struct mbuf *m, *n; - int space = 0; + struct mbuf *m, *n; + int space; if (control == 0) panic("sbappendcontrol"); - for (m = control; ; m = m->m_next) { - space += m->m_len; - if (m->m_next == 0) - break; - } - n = m; /* save pointer to last control buffer */ - for (m = m0; m; m = m->m_next) - space += m->m_len; + space = m_length(control, &n) + m_length(m0, NULL); if (space > sbspace(sb)) return (0); n->m_next = m0; /* concatenate data to control */ diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c index 05916c5..6108645 100644 --- a/sys/net/if_ppp.c +++ b/sys/net/if_ppp.c @@ -758,7 +758,6 @@ pppoutput(ifp, m0, dst, rtp) struct ifqueue *ifq; enum NPmode mode; int len; - struct mbuf *m; #ifdef MAC error = mac_check_ifnet_transmit(ifp, m0); @@ -851,9 +850,7 @@ pppoutput(ifp, m0, dst, rtp) *cp++ = protocol & 0xff; m0->m_len += PPP_HDRLEN; - len = 0; - for (m = m0; m != 0; m = m->m_next) - len += m->m_len; + len = m_length(m0, NULL); if (sc->sc_flags & SC_LOG_OUTPKT) { printf("ppp%d output: ", ifp->if_unit); @@ -1087,9 +1084,7 @@ ppp_dequeue(sc) struct mbuf *mcomp = NULL; int slen, clen; - slen = 0; - for (mp = m; mp != NULL; mp = mp->m_next) - slen += mp->m_len; + slen = m_length(m, NULL); clen = (*sc->sc_xcomp->compress) (sc->sc_xc_state, &mcomp, m, slen, sc->sc_if.if_mtu + PPP_HDRLEN); if (mcomp != NULL) { @@ -1324,9 +1319,7 @@ ppp_inproc(sc, m) sc->sc_stats.ppp_ipackets++; if (sc->sc_flags & SC_LOG_INPKT) { - ilen = 0; - for (mp = m; mp != NULL; mp = mp->m_next) - ilen += mp->m_len; + ilen = m_length(m, NULL); printf("ppp%d: got %d bytes\n", ifp->if_unit, ilen); pppdumpm(m); } @@ -1389,9 +1382,7 @@ ppp_inproc(sc, m) } #endif - ilen = 0; - for (mp = m; mp != NULL; mp = mp->m_next) - ilen += mp->m_len; + ilen = m_length(m, NULL); #ifdef VJC if (sc->sc_flags & SC_VJ_RESET) { diff --git a/sys/netns/idp_usrreq.c b/sys/netns/idp_usrreq.c index 5203961..2642d1a 100644 --- a/sys/netns/idp_usrreq.c +++ b/sys/netns/idp_usrreq.c @@ -144,18 +144,12 @@ idp_output(nsp, m0) register struct mbuf *m; register struct idp *idp; register struct socket *so; - register int len = 0; + register int len; register struct route *ro; struct mbuf *mprev; extern int idpcksum; - /* - * Calculate data length. - */ - for (m = m0; m; m = m->m_next) { - mprev = m; - len += m->m_len; - } + len = m_length(m0, &mprev); /* * Make sure packet is actually of even length. */ diff --git a/sys/netns/spp_usrreq.c b/sys/netns/spp_usrreq.c index 6efe381..c942884 100644 --- a/sys/netns/spp_usrreq.c +++ b/sys/netns/spp_usrreq.c @@ -687,8 +687,7 @@ register struct nspcb *nsp; firstbad = m; /*for (;;) {*/ /* calculate length */ - for (m0 = m, len = 0; m ; m = m->m_next) - len += m->m_len; + len = m_length(m, NULL); if (len > cb->s_mtu) { } /* FINISH THIS diff --git a/sys/netsmb/smb_rq.c b/sys/netsmb/smb_rq.c index 23d9e61..9eff2d5 100644 --- a/sys/netsmb/smb_rq.c +++ b/sys/netsmb/smb_rq.c @@ -421,9 +421,7 @@ smb_t2_placedata(struct mbuf *mtop, u_int16_t offset, u_int16_t count, m0 = m_split(mtop, offset, M_TRYWAIT); if (m0 == NULL) return EBADRPC; - for(len = 0, m = m0; m->m_next; m = m->m_next) - len += m->m_len; - len += m->m_len; + len = m_length(m0, &m); m->m_len -= len - count; if (mdp->md_top == NULL) { md_initm(mdp, m0); diff --git a/sys/nfsclient/nfs_socket.c b/sys/nfsclient/nfs_socket.c index 95e509b..15cf946 100644 --- a/sys/nfsclient/nfs_socket.c +++ b/sys/nfsclient/nfs_socket.c @@ -869,13 +869,7 @@ nfs_request(struct vnode *vp, struct mbuf *mrest, int procnum, rep->r_vp = vp; rep->r_td = td; rep->r_procnum = procnum; - i = 0; - m = mrest; - while (m) { - i += m->m_len; - m = m->m_next; - } - mrest_len = i; + mrest_len = m_length(mrest, NULL); /* * Get the RPC header with authorization. diff --git a/sys/nfsserver/nfs_syscalls.c b/sys/nfsserver/nfs_syscalls.c index c512063..10e0ed2 100644 --- a/sys/nfsserver/nfs_syscalls.c +++ b/sys/nfsserver/nfs_syscalls.c @@ -451,12 +451,7 @@ nfssvc_nfsd(struct thread *td) nfsrv_updatecache(nd, TRUE, mreq); nd->nd_mrep = NULL; case RC_REPLY: - m = mreq; - siz = 0; - while (m) { - siz += m->m_len; - m = m->m_next; - } + siz = m_length(mreq, NULL); if (siz <= 0 || siz > NFS_MAXPACKET) { printf("mbuf siz=%d\n",siz); panic("Bad nfs svc reply"); |