Refactor for clarity and de-duplication of code. Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx> --- fs/nfsd/nfs4xdr.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 73a4b23849e2..ece4e8afe19e 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1470,12 +1470,25 @@ static __be32 nfsd4_decode_bind_conn_to_session(struct nfsd4_compoundargs *argp, return nfserr_bad_xdr; } +static __be32 nfsd4_decode_state_protect_ops(struct nfsd4_compoundargs *argp, + u32 *must_enforce, u32 me_len, + u32 *must_allow, u32 ma_len) +{ + __be32 status; + + status = nfsd4_decode_bitmap4(argp, must_enforce, me_len); + if (status) + return status; + return nfsd4_decode_bitmap4(argp, must_allow, ma_len); +} + static __be32 nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, struct nfsd4_exchange_id *exid) { int dummy, tmp; DECODE_HEAD; + u32 bm[3]; READ_BUF(NFS4_VERIFIER_SIZE); COPYMEM(exid->verifier.data, NFS4_VERIFIER_SIZE); @@ -1494,28 +1507,20 @@ nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, case SP4_NONE: break; case SP4_MACH_CRED: - /* spo_must_enforce */ - status = nfsd4_decode_bitmap4(argp, exid->spo_must_enforce, - ARRAY_SIZE(exid->spo_must_enforce)); - if (status) - goto out; - /* spo_must_allow */ - status = nfsd4_decode_bitmap4(argp, exid->spo_must_allow, - ARRAY_SIZE(exid->spo_must_allow)); + status = nfsd4_decode_state_protect_ops(argp, + exid->spo_must_enforce, + ARRAY_SIZE(exid->spo_must_enforce), + exid->spo_must_allow, + ARRAY_SIZE(exid->spo_must_allow)); if (status) goto out; break; case SP4_SSV: /* ssp_ops */ - READ_BUF(4); - dummy = be32_to_cpup(p++); - READ_BUF(dummy * 4); - p += dummy; - - READ_BUF(4); - dummy = be32_to_cpup(p++); - READ_BUF(dummy * 4); - p += dummy; + status = nfsd4_decode_state_protect_ops(argp, bm, ARRAY_SIZE(bm), + bm, ARRAY_SIZE(bm)); + if (status) + goto out; /* ssp_hash_algs<> */ READ_BUF(4);