aboutsummaryrefslogtreecommitdiff
path: root/sys/nfs
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2001-09-28 04:37:08 +0000
committerPeter Wemm <peter@FreeBSD.org>2001-09-28 04:37:08 +0000
commitb9b0e1920692a0f105f207da98e164630acc4104 (patch)
tree70885e3ccbc8ca40ca489f691745bc22fb96720d /sys/nfs
parentac25bcab7233cb399cb2c6889459a60ea382760b (diff)
downloadsrc-b9b0e1920692a0f105f207da98e164630acc4104.tar.gz
src-b9b0e1920692a0f105f207da98e164630acc4104.zip
Unwind some more macros. NFSMADV() was kinda silly since it was right
next to equivalent m_len adjustments. Move the nfsm_subs.h macros into groups depending on which phase they are used in, since that affects the error recovery requirements. Collect some of the common error checking into a single macro as preparation for unwinding some more. Have nfs_rephead return a value instead of secretly modifying args. Remove some unused function arguments that were being passed around. Clarify nfsm_reply()'s error handling (I hope).
Notes
Notes: svn path=/head/; revision=84079
Diffstat (limited to 'sys/nfs')
-rw-r--r--sys/nfs/nfs_common.c2
-rw-r--r--sys/nfs/nfs_common.h76
2 files changed, 42 insertions, 36 deletions
diff --git a/sys/nfs/nfs_common.c b/sys/nfs/nfs_common.c
index b4123f9cc2b9..029096ab8d73 100644
--- a/sys/nfs/nfs_common.c
+++ b/sys/nfs/nfs_common.c
@@ -209,7 +209,7 @@ nfsm_disct(struct mbuf **mdp, caddr_t *dposp, int siz, int left)
xfer = (siz2 > mp2->m_len) ? mp2->m_len : siz2;
if (xfer > 0) {
bcopy(mtod(mp2, caddr_t), ptr, xfer);
- NFSMADV(mp2, xfer);
+ mp2->m_data += xfer;
mp2->m_len -= xfer;
ptr += xfer;
siz2 -= xfer;
diff --git a/sys/nfs/nfs_common.h b/sys/nfs/nfs_common.h
index a751a6752347..889054d05aed 100644
--- a/sys/nfs/nfs_common.h
+++ b/sys/nfs/nfs_common.h
@@ -50,33 +50,52 @@ extern nfstype nfsv3_type[];
#define nfsv3tov_type(a) nv3tov_type[fxdr_unsigned(u_int32_t,(a))&0x7]
#define vtonfsv3_type(a) txdr_unsigned(nfsv3_type[((int32_t)(a))])
-#define NFSMADV(m, s) \
- do { \
- (m)->m_data += (s); \
- } while (0)
-
int nfs_adv(struct mbuf **, caddr_t *, int, int);
-void *nfsm_build_xx(int s, struct mbuf **mb, caddr_t *bpos);
-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);
void *nfsm_disct(struct mbuf **, caddr_t *, int, int);
+/* ****************************** */
+/* Build request/reply phase macros */
+
+void *nfsm_build_xx(int s, struct mbuf **mb, caddr_t *bpos);
+
#define nfsm_build(c, s) \
(c)nfsm_build_xx((s), &mb, &bpos)
+/* ****************************** */
+/* Interpretation phase macros */
+
+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 **md,
+ caddr_t *dpos);
+int nfsm_adv_xx(int s, u_int32_t **tl, struct mbuf **md, caddr_t *dpos);
+
+/* Error check helpers */
+#define nfsm_dcheck(t1, mrep) \
+do { \
+ if (t1 != 0) { \
+ error = t1; \
+ m_freem((mrep)); \
+ (mrep) = NULL; \
+ goto nfsmout; \
+ } \
+} while (0)
+
+#define nfsm_dcheckp(retp, mrep) \
+do { \
+ if (retp == NULL) { \
+ error = EBADRPC; \
+ m_freem((mrep)); \
+ (mrep) = NULL; \
+ goto nfsmout; \
+ } \
+} while (0)
+
#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; \
- } \
+ nfsm_dcheckp(ret, mrep); \
(c)ret; \
})
@@ -84,23 +103,15 @@ void *nfsm_disct(struct mbuf **, caddr_t *, int, int);
do { \
int t1; \
t1 = nfsm_strsiz_xx(&(s), (m), &tl, &md, &dpos); \
- if (t1) { \
- error = t1; \
- m_freem(mrep); \
- mrep = NULL; \
- goto nfsmout; \
- } \
+ nfsm_dcheck(t1, mrep); \
} while(0)
#define nfsm_mtouio(p,s) \
do {\
- int32_t t1; \
- if ((s) > 0 && (t1 = nfsm_mbuftouio(&md, (p), (s), &dpos)) != 0) { \
- error = t1; \
- m_freem(mrep); \
- mrep = NULL; \
- goto nfsmout; \
- } \
+ int32_t t1 = 0; \
+ if ((s) > 0) \
+ t1 = nfsm_mbuftouio(&md, (p), (s), &dpos); \
+ nfsm_dcheck(t1, mrep); \
} while (0)
#define nfsm_rndup(a) (((a)+3)&(~0x3))
@@ -109,12 +120,7 @@ do {\
do { \
int t1; \
t1 = nfsm_adv_xx((s), &tl, &md, &dpos); \
- if (t1) { \
- error = t1; \
- m_freem(mrep); \
- mrep = NULL; \
- goto nfsmout; \
- } \
+ nfsm_dcheck(t1, mrep); \
} while (0)
#endif