Skip to content

Commit

Permalink
lockd: fix encoder callback prototypes
Browse files Browse the repository at this point in the history
Declare the p_encode callbacks with the proper prototype instead of
casting to kxdreproc_t and losing all type safety.

Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Jeff Layton <[email protected]>
Acked-by: Trond Myklebust <[email protected]>
  • Loading branch information
Christoph Hellwig committed May 15, 2017
1 parent 7d55f7f commit bf96391
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
22 changes: 15 additions & 7 deletions fs/lockd/clnt4xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,9 @@ static void encode_nlm4_lock(struct xdr_stream *xdr,
*/
static void nlm4_xdr_enc_testargs(struct rpc_rqst *req,
struct xdr_stream *xdr,
const struct nlm_args *args)
const void *data)
{
const struct nlm_args *args = data;
const struct nlm_lock *lock = &args->lock;

encode_cookie(xdr, &args->cookie);
Expand All @@ -402,8 +403,9 @@ static void nlm4_xdr_enc_testargs(struct rpc_rqst *req,
*/
static void nlm4_xdr_enc_lockargs(struct rpc_rqst *req,
struct xdr_stream *xdr,
const struct nlm_args *args)
const void *data)
{
const struct nlm_args *args = data;
const struct nlm_lock *lock = &args->lock;

encode_cookie(xdr, &args->cookie);
Expand All @@ -424,8 +426,9 @@ static void nlm4_xdr_enc_lockargs(struct rpc_rqst *req,
*/
static void nlm4_xdr_enc_cancargs(struct rpc_rqst *req,
struct xdr_stream *xdr,
const struct nlm_args *args)
const void *data)
{
const struct nlm_args *args = data;
const struct nlm_lock *lock = &args->lock;

encode_cookie(xdr, &args->cookie);
Expand All @@ -442,8 +445,9 @@ static void nlm4_xdr_enc_cancargs(struct rpc_rqst *req,
*/
static void nlm4_xdr_enc_unlockargs(struct rpc_rqst *req,
struct xdr_stream *xdr,
const struct nlm_args *args)
const void *data)
{
const struct nlm_args *args = data;
const struct nlm_lock *lock = &args->lock;

encode_cookie(xdr, &args->cookie);
Expand All @@ -458,8 +462,10 @@ static void nlm4_xdr_enc_unlockargs(struct rpc_rqst *req,
*/
static void nlm4_xdr_enc_res(struct rpc_rqst *req,
struct xdr_stream *xdr,
const struct nlm_res *result)
const void *data)
{
const struct nlm_res *result = data;

encode_cookie(xdr, &result->cookie);
encode_nlm4_stat(xdr, result->status);
}
Expand All @@ -479,8 +485,10 @@ static void nlm4_xdr_enc_res(struct rpc_rqst *req,
*/
static void nlm4_xdr_enc_testres(struct rpc_rqst *req,
struct xdr_stream *xdr,
const struct nlm_res *result)
const void *data)
{
const struct nlm_res *result = data;

encode_cookie(xdr, &result->cookie);
encode_nlm4_stat(xdr, result->status);
if (result->status == nlm_lck_denied)
Expand Down Expand Up @@ -566,7 +574,7 @@ static int nlm4_xdr_dec_res(struct rpc_rqst *req,
#define PROC(proc, argtype, restype) \
[NLMPROC_##proc] = { \
.p_proc = NLMPROC_##proc, \
.p_encode = (kxdreproc_t)nlm4_xdr_enc_##argtype, \
.p_encode = nlm4_xdr_enc_##argtype, \
.p_decode = (kxdrdproc_t)nlm4_xdr_dec_##restype, \
.p_arglen = NLM4_##argtype##_sz, \
.p_replen = NLM4_##restype##_sz, \
Expand Down
22 changes: 15 additions & 7 deletions fs/lockd/clntxdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,9 @@ static void encode_nlm_lock(struct xdr_stream *xdr,
*/
static void nlm_xdr_enc_testargs(struct rpc_rqst *req,
struct xdr_stream *xdr,
const struct nlm_args *args)
const void *data)
{
const struct nlm_args *args = data;
const struct nlm_lock *lock = &args->lock;

encode_cookie(xdr, &args->cookie);
Expand All @@ -395,8 +396,9 @@ static void nlm_xdr_enc_testargs(struct rpc_rqst *req,
*/
static void nlm_xdr_enc_lockargs(struct rpc_rqst *req,
struct xdr_stream *xdr,
const struct nlm_args *args)
const void *data)
{
const struct nlm_args *args = data;
const struct nlm_lock *lock = &args->lock;

encode_cookie(xdr, &args->cookie);
Expand All @@ -417,8 +419,9 @@ static void nlm_xdr_enc_lockargs(struct rpc_rqst *req,
*/
static void nlm_xdr_enc_cancargs(struct rpc_rqst *req,
struct xdr_stream *xdr,
const struct nlm_args *args)
const void *data)
{
const struct nlm_args *args = data;
const struct nlm_lock *lock = &args->lock;

encode_cookie(xdr, &args->cookie);
Expand All @@ -435,8 +438,9 @@ static void nlm_xdr_enc_cancargs(struct rpc_rqst *req,
*/
static void nlm_xdr_enc_unlockargs(struct rpc_rqst *req,
struct xdr_stream *xdr,
const struct nlm_args *args)
const void *data)
{
const struct nlm_args *args = data;
const struct nlm_lock *lock = &args->lock;

encode_cookie(xdr, &args->cookie);
Expand All @@ -451,8 +455,10 @@ static void nlm_xdr_enc_unlockargs(struct rpc_rqst *req,
*/
static void nlm_xdr_enc_res(struct rpc_rqst *req,
struct xdr_stream *xdr,
const struct nlm_res *result)
const void *data)
{
const struct nlm_res *result = data;

encode_cookie(xdr, &result->cookie);
encode_nlm_stat(xdr, result->status);
}
Expand All @@ -479,8 +485,10 @@ static void encode_nlm_testrply(struct xdr_stream *xdr,

static void nlm_xdr_enc_testres(struct rpc_rqst *req,
struct xdr_stream *xdr,
const struct nlm_res *result)
const void *data)
{
const struct nlm_res *result = data;

encode_cookie(xdr, &result->cookie);
encode_nlm_stat(xdr, result->status);
encode_nlm_testrply(xdr, result);
Expand Down Expand Up @@ -564,7 +572,7 @@ static int nlm_xdr_dec_res(struct rpc_rqst *req,
#define PROC(proc, argtype, restype) \
[NLMPROC_##proc] = { \
.p_proc = NLMPROC_##proc, \
.p_encode = (kxdreproc_t)nlm_xdr_enc_##argtype, \
.p_encode = nlm_xdr_enc_##argtype, \
.p_decode = (kxdrdproc_t)nlm_xdr_dec_##restype, \
.p_arglen = NLM_##argtype##_sz, \
.p_replen = NLM_##restype##_sz, \
Expand Down
8 changes: 4 additions & 4 deletions fs/lockd/mon.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,14 @@ static void encode_priv(struct xdr_stream *xdr, const struct nsm_args *argp)
}

static void nsm_xdr_enc_mon(struct rpc_rqst *req, struct xdr_stream *xdr,
const struct nsm_args *argp)
const void *argp)
{
encode_mon_id(xdr, argp);
encode_priv(xdr, argp);
}

static void nsm_xdr_enc_unmon(struct rpc_rqst *req, struct xdr_stream *xdr,
const struct nsm_args *argp)
const void *argp)
{
encode_mon_id(xdr, argp);
}
Expand Down Expand Up @@ -532,7 +532,7 @@ static int nsm_xdr_dec_stat(struct rpc_rqst *rqstp,
static struct rpc_procinfo nsm_procedures[] = {
[NSMPROC_MON] = {
.p_proc = NSMPROC_MON,
.p_encode = (kxdreproc_t)nsm_xdr_enc_mon,
.p_encode = nsm_xdr_enc_mon,
.p_decode = (kxdrdproc_t)nsm_xdr_dec_stat_res,
.p_arglen = SM_mon_sz,
.p_replen = SM_monres_sz,
Expand All @@ -541,7 +541,7 @@ static struct rpc_procinfo nsm_procedures[] = {
},
[NSMPROC_UNMON] = {
.p_proc = NSMPROC_UNMON,
.p_encode = (kxdreproc_t)nsm_xdr_enc_unmon,
.p_encode = nsm_xdr_enc_unmon,
.p_decode = (kxdrdproc_t)nsm_xdr_dec_stat,
.p_arglen = SM_mon_id_sz,
.p_replen = SM_unmonres_sz,
Expand Down

0 comments on commit bf96391

Please sign in to comment.