Skip to content

Commit 130e205

Browse files
chuckleverJ. Bruce Fields
authored andcommitted
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: Chuck Lever <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent fda4944 commit 130e205

File tree

16 files changed

+183
-183
lines changed

16 files changed

+183
-183
lines changed

fs/lockd/xdr.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,13 @@ nlmsvc_decode_notify(struct svc_rqst *rqstp, struct xdr_stream *xdr)
313313
* Encode Reply results
314314
*/
315315

316-
int
316+
bool
317317
nlmsvc_encode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr)
318318
{
319-
return 1;
319+
return true;
320320
}
321321

322-
int
322+
bool
323323
nlmsvc_encode_testres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
324324
{
325325
struct nlm_res *resp = rqstp->rq_resp;
@@ -328,7 +328,7 @@ nlmsvc_encode_testres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
328328
svcxdr_encode_testrply(xdr, resp);
329329
}
330330

331-
int
331+
bool
332332
nlmsvc_encode_res(struct svc_rqst *rqstp, struct xdr_stream *xdr)
333333
{
334334
struct nlm_res *resp = rqstp->rq_resp;
@@ -337,18 +337,18 @@ nlmsvc_encode_res(struct svc_rqst *rqstp, struct xdr_stream *xdr)
337337
svcxdr_encode_stats(xdr, resp->status);
338338
}
339339

340-
int
340+
bool
341341
nlmsvc_encode_shareres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
342342
{
343343
struct nlm_res *resp = rqstp->rq_resp;
344344

345345
if (!svcxdr_encode_cookie(xdr, &resp->cookie))
346-
return 0;
346+
return false;
347347
if (!svcxdr_encode_stats(xdr, resp->status))
348-
return 0;
348+
return false;
349349
/* sequence */
350350
if (xdr_stream_encode_u32(xdr, 0) < 0)
351-
return 0;
351+
return false;
352352

353-
return 1;
353+
return true;
354354
}

fs/lockd/xdr4.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -312,13 +312,13 @@ nlm4svc_decode_notify(struct svc_rqst *rqstp, struct xdr_stream *xdr)
312312
* Encode Reply results
313313
*/
314314

315-
int
315+
bool
316316
nlm4svc_encode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr)
317317
{
318-
return 1;
318+
return true;
319319
}
320320

321-
int
321+
bool
322322
nlm4svc_encode_testres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
323323
{
324324
struct nlm_res *resp = rqstp->rq_resp;
@@ -327,7 +327,7 @@ nlm4svc_encode_testres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
327327
svcxdr_encode_testrply(xdr, resp);
328328
}
329329

330-
int
330+
bool
331331
nlm4svc_encode_res(struct svc_rqst *rqstp, struct xdr_stream *xdr)
332332
{
333333
struct nlm_res *resp = rqstp->rq_resp;
@@ -336,18 +336,18 @@ nlm4svc_encode_res(struct svc_rqst *rqstp, struct xdr_stream *xdr)
336336
svcxdr_encode_stats(xdr, resp->status);
337337
}
338338

339-
int
339+
bool
340340
nlm4svc_encode_shareres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
341341
{
342342
struct nlm_res *resp = rqstp->rq_resp;
343343

344344
if (!svcxdr_encode_cookie(xdr, &resp->cookie))
345-
return 0;
345+
return false;
346346
if (!svcxdr_encode_stats(xdr, resp->status))
347-
return 0;
347+
return false;
348348
/* sequence */
349349
if (xdr_stream_encode_u32(xdr, 0) < 0)
350-
return 0;
350+
return false;
351351

352-
return 1;
352+
return true;
353353
}

fs/nfs/callback_xdr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ static __be32 nfs4_callback_null(struct svc_rqst *rqstp)
6767
* svc_process_common() looks for an XDR encoder to know when
6868
* not to drop a Reply.
6969
*/
70-
static int nfs4_encode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr)
70+
static bool nfs4_encode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr)
7171
{
72-
return 1;
72+
return true;
7373
}
7474

7575
static __be32 decode_string(struct xdr_stream *xdr, unsigned int *len,

fs/nfsd/nfs2acl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ nfsaclsvc_decode_accessargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
240240
*/
241241

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

282282
/* ACCESS */
283-
static int
283+
static bool
284284
nfsaclsvc_encode_accessres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
285285
{
286286
struct nfsd3_accessres *resp = rqstp->rq_resp;

fs/nfsd/nfs3acl.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ nfs3svc_decode_setaclargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
166166
*/
167167

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

180180
if (!svcxdr_encode_nfsstat3(xdr, resp->status))
181-
return 0;
181+
return false;
182182
switch (resp->status) {
183183
case nfs_ok:
184184
inode = d_inode(dentry);
185185
if (!svcxdr_encode_post_op_attr(rqstp, xdr, &resp->fh))
186-
return 0;
186+
return false;
187187
if (xdr_stream_encode_u32(xdr, resp->mask) < 0)
188-
return 0;
188+
return false;
189189

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

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

@@ -207,18 +207,18 @@ nfs3svc_encode_getaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
207207
resp->mask & NFS_DFACL,
208208
NFS_ACL_DEFAULT);
209209
if (n <= 0)
210-
return 0;
210+
return false;
211211
break;
212212
default:
213213
if (!svcxdr_encode_post_op_attr(rqstp, xdr, &resp->fh))
214-
return 0;
214+
return false;
215215
}
216216

217-
return 1;
217+
return true;
218218
}
219219

220220
/* SETACL */
221-
static int
221+
static bool
222222
nfs3svc_encode_setaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
223223
{
224224
struct nfsd3_attrstat *resp = rqstp->rq_resp;

0 commit comments

Comments
 (0)