diff options
author | peter <peter@FreeBSD.org> | 2001-09-27 22:40:38 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2001-09-27 22:40:38 +0000 |
commit | 2854bb2840809c802db31285bc55e9fc5e73ac20 (patch) | |
tree | 0787f81479ebda92d49c697add33a3151d9b4813 /sys/nfs | |
parent | dd0c7c11066885a54661583d626cfe224c586ce1 (diff) | |
download | FreeBSD-src-2854bb2840809c802db31285bc55e9fc5e73ac20.zip FreeBSD-src-2854bb2840809c802db31285bc55e9fc5e73ac20.tar.gz |
Make nfsm_dissect() have an obvious return value.
Diffstat (limited to 'sys/nfs')
-rw-r--r-- | sys/nfs/nfs_common.c | 43 | ||||
-rw-r--r-- | sys/nfs/nfs_common.h | 22 |
2 files changed, 32 insertions, 33 deletions
diff --git a/sys/nfs/nfs_common.c b/sys/nfs/nfs_common.c index 5635945..b4123f9 100644 --- a/sys/nfs/nfs_common.c +++ b/sys/nfs/nfs_common.c @@ -164,29 +164,30 @@ nfsm_mbuftouio(struct mbuf **mrep, struct uio *uiop, int siz, caddr_t *dpos) /* * Help break down an mbuf chain by setting the first siz bytes contiguous * pointed to by returned val. - * This is used by the macros nfsm_dissect and nfsm_dissecton for tough + * This is used by the macros nfsm_dissect for tough * cases. (The macros use the vars. dpos and dpos2) */ -int -nfsm_disct(struct mbuf **mdp, caddr_t *dposp, int siz, int left, caddr_t *cp2) +void * +nfsm_disct(struct mbuf **mdp, caddr_t *dposp, int siz, int left) { struct mbuf *mp, *mp2; int siz2, xfer; caddr_t ptr; + void *ret; mp = *mdp; while (left == 0) { *mdp = mp = mp->m_next; if (mp == NULL) - return (EBADRPC); + return NULL; left = mp->m_len; *dposp = mtod(mp, caddr_t); } if (left >= siz) { - *cp2 = *dposp; + ret = *dposp; *dposp += siz; } else if (mp->m_next == NULL) { - return (EBADRPC); + return NULL; } else if (siz > MHLEN) { panic("nfs S too big"); } else { @@ -195,7 +196,8 @@ nfsm_disct(struct mbuf **mdp, caddr_t *dposp, int siz, int left, caddr_t *cp2) mp->m_next = mp2; mp->m_len -= left; mp = mp2; - *cp2 = ptr = mtod(mp, caddr_t); + ptr = mtod(mp, caddr_t); + ret = ptr; bcopy(*dposp, ptr, left); /* Copy what was left */ siz2 = siz-left; ptr += left; @@ -203,7 +205,7 @@ nfsm_disct(struct mbuf **mdp, caddr_t *dposp, int siz, int left, caddr_t *cp2) /* Loop around copying up the siz2 bytes */ while (siz2 > 0) { if (mp2 == NULL) - return (EBADRPC); + return NULL; xfer = (siz2 > mp2->m_len) ? mp2->m_len : siz2; if (xfer > 0) { bcopy(mtod(mp2, caddr_t), ptr, xfer); @@ -219,7 +221,7 @@ nfsm_disct(struct mbuf **mdp, caddr_t *dposp, int siz, int left, caddr_t *cp2) *mdp = mp2; *dposp = mtod(mp2, caddr_t); } - return (0); + return ret; } /* @@ -266,33 +268,30 @@ nfsm_build_xx(int s, struct mbuf **mb, caddr_t *bpos) return ret; } -int -nfsm_dissect_xx(void **a, int s, struct mbuf **md, caddr_t *dpos) +void * +nfsm_dissect_xx(int s, struct mbuf **md, caddr_t *dpos) { int t1; char *cp2; + void *ret; t1 = mtod(*md, caddr_t) + (*md)->m_len - *dpos; if (t1 >= s) { - *a = *dpos; + ret = *dpos; *dpos += s; - return 0; + return ret; } - t1 = nfsm_disct(md, dpos, s, t1, &cp2); - if (t1 != 0) - return t1; - *a = cp2; - return 0; + cp2 = nfsm_disct(md, dpos, s, t1); + return cp2; } int nfsm_strsiz_xx(int *s, int m, u_int32_t **tl, struct mbuf **mb, caddr_t *bpos) { - int ret; - ret = nfsm_dissect_xx((void **)tl, NFSX_UNSIGNED, mb, bpos); - if (ret) - return ret; + *tl = nfsm_dissect_xx(NFSX_UNSIGNED, mb, bpos); + if (*tl == NULL) + return EBADRPC; *s = fxdr_unsigned(int32_t, **tl); if (*s > m) return EBADRPC; diff --git a/sys/nfs/nfs_common.h b/sys/nfs/nfs_common.h index c43dd3e..a751a67 100644 --- a/sys/nfs/nfs_common.h +++ b/sys/nfs/nfs_common.h @@ -57,28 +57,28 @@ extern nfstype nfsv3_type[]; int nfs_adv(struct mbuf **, caddr_t *, int, int); void *nfsm_build_xx(int s, struct mbuf **mb, caddr_t *bpos); -int nfsm_dissect_xx(void **a, int s, struct mbuf **md, caddr_t *dpos); +void *nfsm_dissect_xx(int s, struct mbuf **md, caddr_t *dpos); int nfsm_strsiz_xx(int *s, int m, u_int32_t **tl, struct mbuf **mb, caddr_t *bpos); int nfsm_adv_xx(int s, u_int32_t **tl, struct mbuf **md, caddr_t *dpos); u_quad_t nfs_curusec(void); -int nfsm_disct(struct mbuf **, caddr_t *, int, int, caddr_t *); +void *nfsm_disct(struct mbuf **, caddr_t *, int, int); #define nfsm_build(c, s) \ - (c)nfsm_build_xx((s), &mb, &bpos); \ + (c)nfsm_build_xx((s), &mb, &bpos) -/* XXX 'c' arg (type) is not used */ -#define nfsm_dissect(a, c, s) \ -do { \ - int t1; \ - t1 = nfsm_dissect_xx((void **)&(a), (s), &md, &dpos); \ - if (t1) { \ - error = t1; \ +#define nfsm_dissect(c, s) \ +({ \ + void *ret; \ + ret = nfsm_dissect_xx((s), &md, &dpos); \ + if (ret == NULL) { \ + error = EBADRPC; \ m_freem(mrep); \ mrep = NULL; \ goto nfsmout; \ } \ -} while (0) + (c)ret; \ +}) #define nfsm_strsiz(s,m) \ do { \ |