Skip to content

Commit a0d042f

Browse files
committed
NFSD: Clean up nfsd4_encode_rdattr_error()
No need for specialized code here, as this function is invoked only rarely. Convert it to encode to xdr_stream using conventional XDR helpers. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent a0f3c83 commit a0d042f

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

fs/nfsd/nfs4xdr.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3726,21 +3726,22 @@ nfsd4_encode_entry4_fattr(struct nfsd4_readdir *cd, const char *name,
37263726
return nfserr;
37273727
}
37283728

3729-
static __be32 *
3730-
nfsd4_encode_rdattr_error(struct xdr_stream *xdr, __be32 nfserr)
3729+
static __be32
3730+
nfsd4_encode_entry4_rdattr_error(struct xdr_stream *xdr, __be32 nfserr)
37313731
{
3732-
__be32 *p;
3733-
3734-
p = xdr_reserve_space(xdr, 20);
3735-
if (!p)
3736-
return NULL;
3737-
*p++ = htonl(2);
3738-
*p++ = htonl(FATTR4_WORD0_RDATTR_ERROR); /* bmval0 */
3739-
*p++ = htonl(0); /* bmval1 */
3732+
__be32 status;
37403733

3741-
*p++ = htonl(4); /* attribute length */
3742-
*p++ = nfserr; /* no htonl */
3743-
return p;
3734+
/* attrmask */
3735+
status = nfsd4_encode_bitmap4(xdr, FATTR4_WORD0_RDATTR_ERROR, 0, 0);
3736+
if (status != nfs_ok)
3737+
return status;
3738+
/* attr_vals */
3739+
if (xdr_stream_encode_u32(xdr, XDR_UNIT) != XDR_UNIT)
3740+
return nfserr_resource;
3741+
/* rdattr_error */
3742+
if (xdr_stream_encode_be32(xdr, nfserr) != XDR_UNIT)
3743+
return nfserr_resource;
3744+
return nfs_ok;
37443745
}
37453746

37463747
static int
@@ -3812,8 +3813,7 @@ nfsd4_encode_entry4(void *ccdv, const char *name, int namlen,
38123813
*/
38133814
if (!(cd->rd_bmval[0] & FATTR4_WORD0_RDATTR_ERROR))
38143815
goto fail;
3815-
p = nfsd4_encode_rdattr_error(xdr, nfserr);
3816-
if (p == NULL) {
3816+
if (nfsd4_encode_entry4_rdattr_error(xdr, nfserr)) {
38173817
nfserr = nfserr_toosmall;
38183818
goto fail;
38193819
}

0 commit comments

Comments
 (0)