Skip to content

Commit

Permalink
sunrpc: properly type pc_decode callbacks
Browse files Browse the repository at this point in the history
Drop the argp 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 <hch@lst.de>
  • Loading branch information
Christoph Hellwig committed May 15, 2017
1 parent 8537488 commit 026fec7
Show file tree
Hide file tree
Showing 21 changed files with 237 additions and 209 deletions.
2 changes: 1 addition & 1 deletion fs/lockd/svc4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ struct nlm_void { int dummy; };

#define PROC(name, xargt, xrest, argt, rest, respsize) \
{ .pc_func = nlm4svc_proc_##name, \
.pc_decode = (kxdrproc_t) nlm4svc_decode_##xargt, \
.pc_decode = nlm4svc_decode_##xargt, \
.pc_encode = (kxdrproc_t) nlm4svc_encode_##xrest, \
.pc_release = NULL, \
.pc_argsize = sizeof(struct nlm_##argt), \
Expand Down
2 changes: 1 addition & 1 deletion fs/lockd/svcproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ struct nlm_void { int dummy; };

#define PROC(name, xargt, xrest, argt, rest, respsize) \
{ .pc_func = nlmsvc_proc_##name, \
.pc_decode = (kxdrproc_t) nlmsvc_decode_##xargt, \
.pc_decode = nlmsvc_decode_##xargt, \
.pc_encode = (kxdrproc_t) nlmsvc_encode_##xrest, \
.pc_release = NULL, \
.pc_argsize = sizeof(struct nlm_##argt), \
Expand Down
29 changes: 20 additions & 9 deletions fs/lockd/xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ nlm_encode_testres(__be32 *p, struct nlm_res *resp)
* First, the server side XDR functions
*/
int
nlmsvc_decode_testargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
nlmsvc_decode_testargs(struct svc_rqst *rqstp, __be32 *p)
{
struct nlm_args *argp = rqstp->rq_argp;
u32 exclusive;

if (!(p = nlm_decode_cookie(p, &argp->cookie)))
Expand All @@ -207,8 +208,9 @@ nlmsvc_encode_testres(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
}

int
nlmsvc_decode_lockargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
nlmsvc_decode_lockargs(struct svc_rqst *rqstp, __be32 *p)
{
struct nlm_args *argp = rqstp->rq_argp;
u32 exclusive;

if (!(p = nlm_decode_cookie(p, &argp->cookie)))
Expand All @@ -227,8 +229,9 @@ nlmsvc_decode_lockargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
}

int
nlmsvc_decode_cancargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
nlmsvc_decode_cancargs(struct svc_rqst *rqstp, __be32 *p)
{
struct nlm_args *argp = rqstp->rq_argp;
u32 exclusive;

if (!(p = nlm_decode_cookie(p, &argp->cookie)))
Expand All @@ -243,8 +246,10 @@ nlmsvc_decode_cancargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
}

int
nlmsvc_decode_unlockargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
nlmsvc_decode_unlockargs(struct svc_rqst *rqstp, __be32 *p)
{
struct nlm_args *argp = rqstp->rq_argp;

if (!(p = nlm_decode_cookie(p, &argp->cookie))
|| !(p = nlm_decode_lock(p, &argp->lock)))
return 0;
Expand All @@ -253,8 +258,9 @@ nlmsvc_decode_unlockargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
}

int
nlmsvc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
nlmsvc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p)
{
struct nlm_args *argp = rqstp->rq_argp;
struct nlm_lock *lock = &argp->lock;

memset(lock, 0, sizeof(*lock));
Expand Down Expand Up @@ -293,8 +299,9 @@ nlmsvc_encode_res(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
}

int
nlmsvc_decode_notify(struct svc_rqst *rqstp, __be32 *p, struct nlm_args *argp)
nlmsvc_decode_notify(struct svc_rqst *rqstp, __be32 *p)
{
struct nlm_args *argp = rqstp->rq_argp;
struct nlm_lock *lock = &argp->lock;

if (!(p = xdr_decode_string_inplace(p, &lock->caller,
Expand All @@ -305,8 +312,10 @@ nlmsvc_decode_notify(struct svc_rqst *rqstp, __be32 *p, struct nlm_args *argp)
}

int
nlmsvc_decode_reboot(struct svc_rqst *rqstp, __be32 *p, struct nlm_reboot *argp)
nlmsvc_decode_reboot(struct svc_rqst *rqstp, __be32 *p)
{
struct nlm_reboot *argp = rqstp->rq_argp;

if (!(p = xdr_decode_string_inplace(p, &argp->mon, &argp->len, SM_MAXSTRLEN)))
return 0;
argp->state = ntohl(*p++);
Expand All @@ -316,16 +325,18 @@ nlmsvc_decode_reboot(struct svc_rqst *rqstp, __be32 *p, struct nlm_reboot *argp)
}

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

if (!(p = nlm_decode_cookie(p, &resp->cookie)))
return 0;
resp->status = *p++;
return xdr_argsize_check(rqstp, p);
}

int
nlmsvc_decode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy)
nlmsvc_decode_void(struct svc_rqst *rqstp, __be32 *p)
{
return xdr_argsize_check(rqstp, p);
}
Expand Down
29 changes: 20 additions & 9 deletions fs/lockd/xdr4.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,9 @@ nlm4_encode_testres(__be32 *p, struct nlm_res *resp)
* First, the server side XDR functions
*/
int
nlm4svc_decode_testargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
nlm4svc_decode_testargs(struct svc_rqst *rqstp, __be32 *p)
{
struct nlm_args *argp = rqstp->rq_argp;
u32 exclusive;

if (!(p = nlm4_decode_cookie(p, &argp->cookie)))
Expand All @@ -204,8 +205,9 @@ nlm4svc_encode_testres(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
}

int
nlm4svc_decode_lockargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
nlm4svc_decode_lockargs(struct svc_rqst *rqstp, __be32 *p)
{
struct nlm_args *argp = rqstp->rq_argp;
u32 exclusive;

if (!(p = nlm4_decode_cookie(p, &argp->cookie)))
Expand All @@ -224,8 +226,9 @@ nlm4svc_decode_lockargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
}

int
nlm4svc_decode_cancargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
nlm4svc_decode_cancargs(struct svc_rqst *rqstp, __be32 *p)
{
struct nlm_args *argp = rqstp->rq_argp;
u32 exclusive;

if (!(p = nlm4_decode_cookie(p, &argp->cookie)))
Expand All @@ -240,8 +243,10 @@ nlm4svc_decode_cancargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
}

int
nlm4svc_decode_unlockargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
nlm4svc_decode_unlockargs(struct svc_rqst *rqstp, __be32 *p)
{
struct nlm_args *argp = rqstp->rq_argp;

if (!(p = nlm4_decode_cookie(p, &argp->cookie))
|| !(p = nlm4_decode_lock(p, &argp->lock)))
return 0;
Expand All @@ -250,8 +255,9 @@ nlm4svc_decode_unlockargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
}

int
nlm4svc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
nlm4svc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p)
{
struct nlm_args *argp = rqstp->rq_argp;
struct nlm_lock *lock = &argp->lock;

memset(lock, 0, sizeof(*lock));
Expand Down Expand Up @@ -290,8 +296,9 @@ nlm4svc_encode_res(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
}

int
nlm4svc_decode_notify(struct svc_rqst *rqstp, __be32 *p, struct nlm_args *argp)
nlm4svc_decode_notify(struct svc_rqst *rqstp, __be32 *p)
{
struct nlm_args *argp = rqstp->rq_argp;
struct nlm_lock *lock = &argp->lock;

if (!(p = xdr_decode_string_inplace(p, &lock->caller,
Expand All @@ -302,8 +309,10 @@ nlm4svc_decode_notify(struct svc_rqst *rqstp, __be32 *p, struct nlm_args *argp)
}

int
nlm4svc_decode_reboot(struct svc_rqst *rqstp, __be32 *p, struct nlm_reboot *argp)
nlm4svc_decode_reboot(struct svc_rqst *rqstp, __be32 *p)
{
struct nlm_reboot *argp = rqstp->rq_argp;

if (!(p = xdr_decode_string_inplace(p, &argp->mon, &argp->len, SM_MAXSTRLEN)))
return 0;
argp->state = ntohl(*p++);
Expand All @@ -313,16 +322,18 @@ nlm4svc_decode_reboot(struct svc_rqst *rqstp, __be32 *p, struct nlm_reboot *argp
}

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

if (!(p = nlm4_decode_cookie(p, &resp->cookie)))
return 0;
resp->status = *p++;
return xdr_argsize_check(rqstp, p);
}

int
nlm4svc_decode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy)
nlm4svc_decode_void(struct svc_rqst *rqstp, __be32 *p)
{
return xdr_argsize_check(rqstp, p);
}
Expand Down
4 changes: 2 additions & 2 deletions fs/nfs/callback_xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static __be32 nfs4_callback_null(struct svc_rqst *rqstp)
return htonl(NFS4_OK);
}

static int nfs4_decode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy)
static int nfs4_decode_void(struct svc_rqst *rqstp, __be32 *p)
{
return xdr_argsize_check(rqstp, p);
}
Expand Down Expand Up @@ -998,7 +998,7 @@ static struct callback_op callback_ops[] = {
static struct svc_procedure nfs4_callback_procedures1[] = {
[CB_NULL] = {
.pc_func = nfs4_callback_null,
.pc_decode = (kxdrproc_t)nfs4_decode_void,
.pc_decode = nfs4_decode_void,
.pc_encode = (kxdrproc_t)nfs4_encode_void,
.pc_xdrressize = 1,
},
Expand Down
21 changes: 12 additions & 9 deletions fs/nfsd/nfs2acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,10 @@ static __be32 nfsacld_proc_access(struct svc_rqst *rqstp)
/*
* XDR decode functions
*/
static int nfsaclsvc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p,
struct nfsd3_getaclargs *argp)
static int nfsaclsvc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p)
{
struct nfsd3_getaclargs *argp = rqstp->rq_argp;

p = nfs2svc_decode_fh(p, &argp->fh);
if (!p)
return 0;
Expand All @@ -194,9 +195,9 @@ static int nfsaclsvc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p,
}


static int nfsaclsvc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p,
struct nfsd3_setaclargs *argp)
static int nfsaclsvc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p)
{
struct nfsd3_setaclargs *argp = rqstp->rq_argp;
struct kvec *head = rqstp->rq_arg.head;
unsigned int base;
int n;
Expand All @@ -220,18 +221,20 @@ static int nfsaclsvc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p,
return (n > 0);
}

static int nfsaclsvc_decode_fhandleargs(struct svc_rqst *rqstp, __be32 *p,
struct nfsd_fhandle *argp)
static int nfsaclsvc_decode_fhandleargs(struct svc_rqst *rqstp, __be32 *p)
{
struct nfsd_fhandle *argp = rqstp->rq_argp;

p = nfs2svc_decode_fh(p, &argp->fh);
if (!p)
return 0;
return xdr_argsize_check(rqstp, p);
}

static int nfsaclsvc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p,
struct nfsd3_accessargs *argp)
static int nfsaclsvc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p)
{
struct nfsd3_accessargs *argp = rqstp->rq_argp;

p = nfs2svc_decode_fh(p, &argp->fh);
if (!p)
return 0;
Expand Down Expand Up @@ -351,7 +354,7 @@ struct nfsd3_voidargs { int dummy; };
#define PROC(name, argt, rest, relt, cache, respsize) \
{ \
.pc_func = nfsacld_proc_##name, \
.pc_decode = (kxdrproc_t) nfsaclsvc_decode_##argt##args, \
.pc_decode = nfsaclsvc_decode_##argt##args, \
.pc_encode = (kxdrproc_t) nfsaclsvc_encode_##rest##res, \
.pc_release = nfsaclsvc_release_##relt, \
.pc_argsize = sizeof(struct nfsd3_##argt##args), \
Expand Down
11 changes: 6 additions & 5 deletions fs/nfsd/nfs3acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,10 @@ static __be32 nfsd3_proc_setacl(struct svc_rqst *rqstp)
/*
* XDR decode functions
*/
static int nfs3svc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p,
struct nfsd3_getaclargs *args)
static int nfs3svc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p)
{
struct nfsd3_getaclargs *args = rqstp->rq_argp;

p = nfs3svc_decode_fh(p, &args->fh);
if (!p)
return 0;
Expand All @@ -136,9 +137,9 @@ static int nfs3svc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p,
}


static int nfs3svc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p,
struct nfsd3_setaclargs *args)
static int nfs3svc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p)
{
struct nfsd3_setaclargs *args = rqstp->rq_argp;
struct kvec *head = rqstp->rq_arg.head;
unsigned int base;
int n;
Expand Down Expand Up @@ -241,7 +242,7 @@ struct nfsd3_voidargs { int dummy; };
#define PROC(name, argt, rest, relt, cache, respsize) \
{ \
.pc_func = nfsd3_proc_##name, \
.pc_decode = (kxdrproc_t) nfs3svc_decode_##argt##args, \
.pc_decode = nfs3svc_decode_##argt##args, \
.pc_encode = (kxdrproc_t) nfs3svc_encode_##rest##res, \
.pc_release = nfs3svc_release_##relt, \
.pc_argsize = sizeof(struct nfsd3_##argt##args), \
Expand Down
Loading

0 comments on commit 026fec7

Please sign in to comment.