Skip to content

Commit c44b31c

Browse files
chuckleverJ. Bruce Fields
authored andcommitted
SUNRPC: Change return value type of .pc_decode
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_decode return only true or false. Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 16c6636 commit c44b31c

File tree

15 files changed

+274
-273
lines changed

15 files changed

+274
-273
lines changed

fs/lockd/xdr.c

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -145,129 +145,129 @@ svcxdr_encode_testrply(struct xdr_stream *xdr, const struct nlm_res *resp)
145145
* Decode Call arguments
146146
*/
147147

148-
int
148+
bool
149149
nlmsvc_decode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr)
150150
{
151-
return 1;
151+
return true;
152152
}
153153

154-
int
154+
bool
155155
nlmsvc_decode_testargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
156156
{
157157
struct nlm_args *argp = rqstp->rq_argp;
158158
u32 exclusive;
159159

160160
if (!svcxdr_decode_cookie(xdr, &argp->cookie))
161-
return 0;
161+
return false;
162162
if (xdr_stream_decode_bool(xdr, &exclusive) < 0)
163-
return 0;
163+
return false;
164164
if (!svcxdr_decode_lock(xdr, &argp->lock))
165-
return 0;
165+
return false;
166166
if (exclusive)
167167
argp->lock.fl.fl_type = F_WRLCK;
168168

169-
return 1;
169+
return true;
170170
}
171171

172-
int
172+
bool
173173
nlmsvc_decode_lockargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
174174
{
175175
struct nlm_args *argp = rqstp->rq_argp;
176176
u32 exclusive;
177177

178178
if (!svcxdr_decode_cookie(xdr, &argp->cookie))
179-
return 0;
179+
return false;
180180
if (xdr_stream_decode_bool(xdr, &argp->block) < 0)
181-
return 0;
181+
return false;
182182
if (xdr_stream_decode_bool(xdr, &exclusive) < 0)
183-
return 0;
183+
return false;
184184
if (!svcxdr_decode_lock(xdr, &argp->lock))
185-
return 0;
185+
return false;
186186
if (exclusive)
187187
argp->lock.fl.fl_type = F_WRLCK;
188188
if (xdr_stream_decode_bool(xdr, &argp->reclaim) < 0)
189-
return 0;
189+
return false;
190190
if (xdr_stream_decode_u32(xdr, &argp->state) < 0)
191-
return 0;
191+
return false;
192192
argp->monitor = 1; /* monitor client by default */
193193

194-
return 1;
194+
return true;
195195
}
196196

197-
int
197+
bool
198198
nlmsvc_decode_cancargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
199199
{
200200
struct nlm_args *argp = rqstp->rq_argp;
201201
u32 exclusive;
202202

203203
if (!svcxdr_decode_cookie(xdr, &argp->cookie))
204-
return 0;
204+
return false;
205205
if (xdr_stream_decode_bool(xdr, &argp->block) < 0)
206-
return 0;
206+
return false;
207207
if (xdr_stream_decode_bool(xdr, &exclusive) < 0)
208-
return 0;
208+
return false;
209209
if (!svcxdr_decode_lock(xdr, &argp->lock))
210-
return 0;
210+
return false;
211211
if (exclusive)
212212
argp->lock.fl.fl_type = F_WRLCK;
213213

214-
return 1;
214+
return true;
215215
}
216216

217-
int
217+
bool
218218
nlmsvc_decode_unlockargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
219219
{
220220
struct nlm_args *argp = rqstp->rq_argp;
221221

222222
if (!svcxdr_decode_cookie(xdr, &argp->cookie))
223-
return 0;
223+
return false;
224224
if (!svcxdr_decode_lock(xdr, &argp->lock))
225-
return 0;
225+
return false;
226226
argp->lock.fl.fl_type = F_UNLCK;
227227

228-
return 1;
228+
return true;
229229
}
230230

231-
int
231+
bool
232232
nlmsvc_decode_res(struct svc_rqst *rqstp, struct xdr_stream *xdr)
233233
{
234234
struct nlm_res *resp = rqstp->rq_argp;
235235

236236
if (!svcxdr_decode_cookie(xdr, &resp->cookie))
237-
return 0;
237+
return false;
238238
if (!svcxdr_decode_stats(xdr, &resp->status))
239-
return 0;
239+
return false;
240240

241-
return 1;
241+
return true;
242242
}
243243

244-
int
244+
bool
245245
nlmsvc_decode_reboot(struct svc_rqst *rqstp, struct xdr_stream *xdr)
246246
{
247247
struct nlm_reboot *argp = rqstp->rq_argp;
248248
__be32 *p;
249249
u32 len;
250250

251251
if (xdr_stream_decode_u32(xdr, &len) < 0)
252-
return 0;
252+
return false;
253253
if (len > SM_MAXSTRLEN)
254-
return 0;
254+
return false;
255255
p = xdr_inline_decode(xdr, len);
256256
if (!p)
257-
return 0;
257+
return false;
258258
argp->len = len;
259259
argp->mon = (char *)p;
260260
if (xdr_stream_decode_u32(xdr, &argp->state) < 0)
261-
return 0;
261+
return false;
262262
p = xdr_inline_decode(xdr, SM_PRIV_SIZE);
263263
if (!p)
264-
return 0;
264+
return false;
265265
memcpy(&argp->priv.data, p, sizeof(argp->priv.data));
266266

267-
return 1;
267+
return true;
268268
}
269269

270-
int
270+
bool
271271
nlmsvc_decode_shareargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
272272
{
273273
struct nlm_args *argp = rqstp->rq_argp;
@@ -278,34 +278,34 @@ nlmsvc_decode_shareargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
278278
lock->svid = ~(u32)0;
279279

280280
if (!svcxdr_decode_cookie(xdr, &argp->cookie))
281-
return 0;
281+
return false;
282282
if (!svcxdr_decode_string(xdr, &lock->caller, &lock->len))
283-
return 0;
283+
return false;
284284
if (!svcxdr_decode_fhandle(xdr, &lock->fh))
285-
return 0;
285+
return false;
286286
if (!svcxdr_decode_owner(xdr, &lock->oh))
287-
return 0;
287+
return false;
288288
/* XXX: Range checks are missing in the original code */
289289
if (xdr_stream_decode_u32(xdr, &argp->fsm_mode) < 0)
290-
return 0;
290+
return false;
291291
if (xdr_stream_decode_u32(xdr, &argp->fsm_access) < 0)
292-
return 0;
292+
return false;
293293

294-
return 1;
294+
return true;
295295
}
296296

297-
int
297+
bool
298298
nlmsvc_decode_notify(struct svc_rqst *rqstp, struct xdr_stream *xdr)
299299
{
300300
struct nlm_args *argp = rqstp->rq_argp;
301301
struct nlm_lock *lock = &argp->lock;
302302

303303
if (!svcxdr_decode_string(xdr, &lock->caller, &lock->len))
304-
return 0;
304+
return false;
305305
if (xdr_stream_decode_u32(xdr, &argp->state) < 0)
306-
return 0;
306+
return false;
307307

308-
return 1;
308+
return true;
309309
}
310310

311311

0 commit comments

Comments
 (0)