Skip to content

Commit

Permalink
SUNRPC: Change return value type of .pc_encode
Browse files Browse the repository at this point in the history
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: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
  • Loading branch information
Chuck Lever authored and J. Bruce Fields committed Oct 13, 2021
1 parent fda4944 commit 130e205
Show file tree
Hide file tree
Showing 16 changed files with 183 additions and 183 deletions.
18 changes: 9 additions & 9 deletions fs/lockd/xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}
18 changes: 9 additions & 9 deletions fs/lockd/xdr4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}
4 changes: 2 additions & 2 deletions fs/nfs/callback_xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions fs/nfsd/nfs2acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions fs/nfsd/nfs3acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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;
}

Expand All @@ -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;
Expand Down
Loading

0 comments on commit 130e205

Please sign in to comment.