Skip to content

Commit

Permalink
sunrpc: properly type pc_encode callbacks
Browse files Browse the repository at this point in the history
Drop the resp argument as it can trivially be derived from the rqstp
argument.  With that all functions now have the same prototype, and we
can remove the unsafe casting to kxdrproc_t.

Signed-off-by: Christoph Hellwig <[email protected]>
Acked-by: Trond Myklebust <[email protected]>
  • Loading branch information
Christoph Hellwig committed May 15, 2017
1 parent 026fec7 commit 63f8de3
Show file tree
Hide file tree
Showing 21 changed files with 185 additions and 170 deletions.
2 changes: 1 addition & 1 deletion fs/lockd/svc4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ struct nlm_void { int dummy; };
#define PROC(name, xargt, xrest, argt, rest, respsize) \
{ .pc_func = nlm4svc_proc_##name, \
.pc_decode = nlm4svc_decode_##xargt, \
.pc_encode = (kxdrproc_t) nlm4svc_encode_##xrest, \
.pc_encode = nlm4svc_encode_##xrest, \
.pc_release = NULL, \
.pc_argsize = sizeof(struct nlm_##argt), \
.pc_ressize = sizeof(struct nlm_##rest), \
Expand Down
2 changes: 1 addition & 1 deletion fs/lockd/svcproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ struct nlm_void { int dummy; };
#define PROC(name, xargt, xrest, argt, rest, respsize) \
{ .pc_func = nlmsvc_proc_##name, \
.pc_decode = nlmsvc_decode_##xargt, \
.pc_encode = (kxdrproc_t) nlmsvc_encode_##xrest, \
.pc_encode = nlmsvc_encode_##xrest, \
.pc_release = NULL, \
.pc_argsize = sizeof(struct nlm_##argt), \
.pc_ressize = sizeof(struct nlm_##rest), \
Expand Down
14 changes: 10 additions & 4 deletions fs/lockd/xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,10 @@ nlmsvc_decode_testargs(struct svc_rqst *rqstp, __be32 *p)
}

int
nlmsvc_encode_testres(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
nlmsvc_encode_testres(struct svc_rqst *rqstp, __be32 *p)
{
struct nlm_res *resp = rqstp->rq_resp;

if (!(p = nlm_encode_testres(p, resp)))
return 0;
return xdr_ressize_check(rqstp, p);
Expand Down Expand Up @@ -280,8 +282,10 @@ nlmsvc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p)
}

int
nlmsvc_encode_shareres(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
nlmsvc_encode_shareres(struct svc_rqst *rqstp, __be32 *p)
{
struct nlm_res *resp = rqstp->rq_resp;

if (!(p = nlm_encode_cookie(p, &resp->cookie)))
return 0;
*p++ = resp->status;
Expand All @@ -290,8 +294,10 @@ nlmsvc_encode_shareres(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
}

int
nlmsvc_encode_res(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
nlmsvc_encode_res(struct svc_rqst *rqstp, __be32 *p)
{
struct nlm_res *resp = rqstp->rq_resp;

if (!(p = nlm_encode_cookie(p, &resp->cookie)))
return 0;
*p++ = resp->status;
Expand Down Expand Up @@ -342,7 +348,7 @@ nlmsvc_decode_void(struct svc_rqst *rqstp, __be32 *p)
}

int
nlmsvc_encode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy)
nlmsvc_encode_void(struct svc_rqst *rqstp, __be32 *p)
{
return xdr_ressize_check(rqstp, p);
}
14 changes: 10 additions & 4 deletions fs/lockd/xdr4.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,10 @@ nlm4svc_decode_testargs(struct svc_rqst *rqstp, __be32 *p)
}

int
nlm4svc_encode_testres(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
nlm4svc_encode_testres(struct svc_rqst *rqstp, __be32 *p)
{
struct nlm_res *resp = rqstp->rq_resp;

if (!(p = nlm4_encode_testres(p, resp)))
return 0;
return xdr_ressize_check(rqstp, p);
Expand Down Expand Up @@ -277,8 +279,10 @@ nlm4svc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p)
}

int
nlm4svc_encode_shareres(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
nlm4svc_encode_shareres(struct svc_rqst *rqstp, __be32 *p)
{
struct nlm_res *resp = rqstp->rq_resp;

if (!(p = nlm4_encode_cookie(p, &resp->cookie)))
return 0;
*p++ = resp->status;
Expand All @@ -287,8 +291,10 @@ nlm4svc_encode_shareres(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
}

int
nlm4svc_encode_res(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
nlm4svc_encode_res(struct svc_rqst *rqstp, __be32 *p)
{
struct nlm_res *resp = rqstp->rq_resp;

if (!(p = nlm4_encode_cookie(p, &resp->cookie)))
return 0;
*p++ = resp->status;
Expand Down Expand Up @@ -339,7 +345,7 @@ nlm4svc_decode_void(struct svc_rqst *rqstp, __be32 *p)
}

int
nlm4svc_encode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy)
nlm4svc_encode_void(struct svc_rqst *rqstp, __be32 *p)
{
return xdr_ressize_check(rqstp, p);
}
6 changes: 3 additions & 3 deletions fs/nfs/callback_xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static int nfs4_decode_void(struct svc_rqst *rqstp, __be32 *p)
return xdr_argsize_check(rqstp, p);
}

static int nfs4_encode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy)
static int nfs4_encode_void(struct svc_rqst *rqstp, __be32 *p)
{
return xdr_ressize_check(rqstp, p);
}
Expand Down Expand Up @@ -999,12 +999,12 @@ static struct svc_procedure nfs4_callback_procedures1[] = {
[CB_NULL] = {
.pc_func = nfs4_callback_null,
.pc_decode = nfs4_decode_void,
.pc_encode = (kxdrproc_t)nfs4_encode_void,
.pc_encode = nfs4_encode_void,
.pc_xdrressize = 1,
},
[CB_COMPOUND] = {
.pc_func = nfs4_callback_compound,
.pc_encode = (kxdrproc_t)nfs4_encode_void,
.pc_encode = nfs4_encode_void,
.pc_argsize = 256,
.pc_ressize = 256,
.pc_xdrressize = NFS4_CALLBACK_BUFSIZE,
Expand Down
18 changes: 10 additions & 8 deletions fs/nfsd/nfs2acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,15 @@ static int nfsaclsvc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p)
* There must be an encoding function for void results so svc_process
* will work properly.
*/
static int nfsaclsvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p, void *dummy)
static int nfsaclsvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p)
{
return xdr_ressize_check(rqstp, p);
}

/* GETACL */
static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p,
struct nfsd3_getaclres *resp)
static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p)
{
struct nfsd3_getaclres *resp = rqstp->rq_resp;
struct dentry *dentry = resp->fh.fh_dentry;
struct inode *inode;
struct kvec *head = rqstp->rq_res.head;
Expand Down Expand Up @@ -302,17 +302,19 @@ static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p,
return (n > 0);
}

static int nfsaclsvc_encode_attrstatres(struct svc_rqst *rqstp, __be32 *p,
struct nfsd_attrstat *resp)
static int nfsaclsvc_encode_attrstatres(struct svc_rqst *rqstp, __be32 *p)
{
struct nfsd_attrstat *resp = rqstp->rq_resp;

p = nfs2svc_encode_fattr(rqstp, p, &resp->fh, &resp->stat);
return xdr_ressize_check(rqstp, p);
}

/* ACCESS */
static int nfsaclsvc_encode_accessres(struct svc_rqst *rqstp, __be32 *p,
struct nfsd3_accessres *resp)
static int nfsaclsvc_encode_accessres(struct svc_rqst *rqstp, __be32 *p)
{
struct nfsd3_accessres *resp = rqstp->rq_resp;

p = nfs2svc_encode_fattr(rqstp, p, &resp->fh, &resp->stat);
*p++ = htonl(resp->access);
return xdr_ressize_check(rqstp, p);
Expand Down Expand Up @@ -355,7 +357,7 @@ struct nfsd3_voidargs { int dummy; };
{ \
.pc_func = nfsacld_proc_##name, \
.pc_decode = nfsaclsvc_decode_##argt##args, \
.pc_encode = (kxdrproc_t) nfsaclsvc_encode_##rest##res, \
.pc_encode = nfsaclsvc_encode_##rest##res, \
.pc_release = nfsaclsvc_release_##relt, \
.pc_argsize = sizeof(struct nfsd3_##argt##args), \
.pc_ressize = sizeof(struct nfsd3_##rest##res), \
Expand Down
11 changes: 6 additions & 5 deletions fs/nfsd/nfs3acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ static int nfs3svc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p)
*/

/* GETACL */
static int nfs3svc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p,
struct nfsd3_getaclres *resp)
static int nfs3svc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p)
{
struct nfsd3_getaclres *resp = rqstp->rq_resp;
struct dentry *dentry = resp->fh.fh_dentry;

p = nfs3svc_encode_post_op_attr(rqstp, p, &resp->fh);
Expand Down Expand Up @@ -213,9 +213,10 @@ static int nfs3svc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p,
}

/* SETACL */
static int nfs3svc_encode_setaclres(struct svc_rqst *rqstp, __be32 *p,
struct nfsd3_attrstat *resp)
static int nfs3svc_encode_setaclres(struct svc_rqst *rqstp, __be32 *p)
{
struct nfsd3_attrstat *resp = rqstp->rq_resp;

p = nfs3svc_encode_post_op_attr(rqstp, p, &resp->fh);

return xdr_ressize_check(rqstp, p);
Expand Down Expand Up @@ -243,7 +244,7 @@ struct nfsd3_voidargs { int dummy; };
{ \
.pc_func = nfsd3_proc_##name, \
.pc_decode = nfs3svc_decode_##argt##args, \
.pc_encode = (kxdrproc_t) nfs3svc_encode_##rest##res, \
.pc_encode = nfs3svc_encode_##rest##res, \
.pc_release = nfs3svc_release_##relt, \
.pc_argsize = sizeof(struct nfsd3_##argt##args), \
.pc_ressize = sizeof(struct nfsd3_##rest##res), \
Expand Down
Loading

0 comments on commit 63f8de3

Please sign in to comment.