Commit 130e2054 authored by Chuck Lever's avatar Chuck Lever Committed by J. Bruce Fields
Browse files

SUNRPC: Change return value type of .pc_encode



Returning an undecorated integer is an age-old trope, but it's
not clear (even to previous experts in this code) that the only
valid return values are 1 and 0. These functions do not return
a negative errno, rpc_stat value, or a positive length.

Document there are only two valid return values by having
.pc_encode return only true or false.

Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent fda49441
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -313,13 +313,13 @@ nlmsvc_decode_notify(struct svc_rqst *rqstp, struct xdr_stream *xdr)
 * Encode Reply results
 */

int
bool
nlmsvc_encode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	return 1;
	return true;
}

int
bool
nlmsvc_encode_testres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct nlm_res *resp = rqstp->rq_resp;
@@ -328,7 +328,7 @@ nlmsvc_encode_testres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
		svcxdr_encode_testrply(xdr, resp);
}

int
bool
nlmsvc_encode_res(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct nlm_res *resp = rqstp->rq_resp;
@@ -337,18 +337,18 @@ nlmsvc_encode_res(struct svc_rqst *rqstp, struct xdr_stream *xdr)
		svcxdr_encode_stats(xdr, resp->status);
}

int
bool
nlmsvc_encode_shareres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct nlm_res *resp = rqstp->rq_resp;

	if (!svcxdr_encode_cookie(xdr, &resp->cookie))
		return 0;
		return false;
	if (!svcxdr_encode_stats(xdr, resp->status))
		return 0;
		return false;
	/* sequence */
	if (xdr_stream_encode_u32(xdr, 0) < 0)
		return 0;
		return false;

	return 1;
	return true;
}
+9 −9
Original line number Diff line number Diff line
@@ -312,13 +312,13 @@ nlm4svc_decode_notify(struct svc_rqst *rqstp, struct xdr_stream *xdr)
 * Encode Reply results
 */

int
bool
nlm4svc_encode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	return 1;
	return true;
}

int
bool
nlm4svc_encode_testres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct nlm_res *resp = rqstp->rq_resp;
@@ -327,7 +327,7 @@ nlm4svc_encode_testres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
		svcxdr_encode_testrply(xdr, resp);
}

int
bool
nlm4svc_encode_res(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct nlm_res *resp = rqstp->rq_resp;
@@ -336,18 +336,18 @@ nlm4svc_encode_res(struct svc_rqst *rqstp, struct xdr_stream *xdr)
		svcxdr_encode_stats(xdr, resp->status);
}

int
bool
nlm4svc_encode_shareres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct nlm_res *resp = rqstp->rq_resp;

	if (!svcxdr_encode_cookie(xdr, &resp->cookie))
		return 0;
		return false;
	if (!svcxdr_encode_stats(xdr, resp->status))
		return 0;
		return false;
	/* sequence */
	if (xdr_stream_encode_u32(xdr, 0) < 0)
		return 0;
		return false;

	return 1;
	return true;
}
+2 −2
Original line number Diff line number Diff line
@@ -67,9 +67,9 @@ static __be32 nfs4_callback_null(struct svc_rqst *rqstp)
 * svc_process_common() looks for an XDR encoder to know when
 * not to drop a Reply.
 */
static int nfs4_encode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr)
static bool nfs4_encode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	return 1;
	return true;
}

static __be32 decode_string(struct xdr_stream *xdr, unsigned int *len,
+2 −2
Original line number Diff line number Diff line
@@ -240,7 +240,7 @@ nfsaclsvc_decode_accessargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
 */

/* GETACL */
static int
static bool
nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct nfsd3_getaclres *resp = rqstp->rq_resp;
@@ -280,7 +280,7 @@ nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
}

/* ACCESS */
static int
static bool
nfsaclsvc_encode_accessres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct nfsd3_accessres *resp = rqstp->rq_resp;
+9 −9
Original line number Diff line number Diff line
@@ -166,7 +166,7 @@ nfs3svc_decode_setaclargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
 */

/* GETACL */
static int
static bool
nfs3svc_encode_getaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct nfsd3_getaclres *resp = rqstp->rq_resp;
@@ -178,14 +178,14 @@ nfs3svc_encode_getaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
	int w;

	if (!svcxdr_encode_nfsstat3(xdr, resp->status))
		return 0;
		return false;
	switch (resp->status) {
	case nfs_ok:
		inode = d_inode(dentry);
		if (!svcxdr_encode_post_op_attr(rqstp, xdr, &resp->fh))
			return 0;
			return false;
		if (xdr_stream_encode_u32(xdr, resp->mask) < 0)
			return 0;
			return false;

		base = (char *)xdr->p - (char *)head->iov_base;

@@ -194,7 +194,7 @@ nfs3svc_encode_getaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
			(resp->mask & NFS_DFACL) ? resp->acl_default : NULL);
		while (w > 0) {
			if (!*(rqstp->rq_next_page++))
				return 0;
				return false;
			w -= PAGE_SIZE;
		}

@@ -207,18 +207,18 @@ nfs3svc_encode_getaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
					  resp->mask & NFS_DFACL,
					  NFS_ACL_DEFAULT);
		if (n <= 0)
			return 0;
			return false;
		break;
	default:
		if (!svcxdr_encode_post_op_attr(rqstp, xdr, &resp->fh))
			return 0;
			return false;
	}

	return 1;
	return true;
}

/* SETACL */
static int
static bool
nfs3svc_encode_setaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct nfsd3_attrstat *resp = rqstp->rq_resp;
Loading