Skip to content

Commit

Permalink
Change declaration of function map
Browse files Browse the repository at this point in the history
Newer compilers complain if funciton is declared w/o arguments,
so we redeclare the xdrptoc_t as xdrfn and give it proper arguments

Signed-off-by: Simo Sorce <[email protected]>
  • Loading branch information
simo5 committed Feb 10, 2025
1 parent 27bdf92 commit 5db93aa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions rpcgen/gp_xdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

#include "gssrpc/rpc.h"

/* Equivalent to xdrptoc_t but with proper arguments so that modern
* compilers do not complain */
typedef int xdrfn(XDR *, void *);

#define xdr_u_quad_t gp_xdr_uint64_t

bool_t gp_xdr_uint64_t(XDR *xdrs, uint64_t *objp);
Expand Down
8 changes: 6 additions & 2 deletions src/client/gpm_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,8 @@ int gpm_make_call(int proc, union gp_rpc_arg *arg, union gp_rpc_res *res)
gp_rpc_msg msg;
XDR xdr_call_ctx = {0};
XDR xdr_reply_ctx = {0};
xdrfn *arg_fn;
xdrfn *res_fn;
char *send_buffer = NULL;
char *recv_buffer = NULL;
uint32_t send_length;
Expand Down Expand Up @@ -726,7 +728,8 @@ int gpm_make_call(int proc, union gp_rpc_arg *arg, union gp_rpc_res *res)
}

/* encode data */
xdrok = gpm_xdr_set[proc].arg_fn(&xdr_call_ctx, (char *)arg);
arg_fn = gpm_xdr_set[proc].arg_fn;
xdrok = arg_fn(&xdr_call_ctx, arg);
if (!xdrok) {
ret = EINVAL;
goto done;
Expand Down Expand Up @@ -765,7 +768,8 @@ int gpm_make_call(int proc, union gp_rpc_arg *arg, union gp_rpc_res *res)
}

/* decode answer */
xdrok = gpm_xdr_set[proc].res_fn(&xdr_reply_ctx, (char *)res);
res_fn = gpm_xdr_set[proc].res_fn;
xdrok = res_fn(&xdr_reply_ctx, res);
if (!xdrok) {
ret = EINVAL;
}
Expand Down
8 changes: 6 additions & 2 deletions src/gp_rpc_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ static int gp_rpc_decode_call(XDR *xdr_call_ctx,
gp_rpc_accept_status *acc,
gp_rpc_reject_status *rej)
{
xdrfn *arg_fn;
bool xdrok;
int ret;

Expand All @@ -204,7 +205,8 @@ static int gp_rpc_decode_call(XDR *xdr_call_ctx,
return ret;
}

xdrok = gp_xdr_set[*proc].arg_fn(xdr_call_ctx, (char *)arg);
arg_fn = gp_xdr_set[*proc].arg_fn;
xdrok = arg_fn(xdr_call_ctx, arg);
if (!xdrok) {
*acc = GP_RPC_GARBAGE_ARGS;
return EINVAL;
Expand Down Expand Up @@ -283,6 +285,7 @@ static int gp_rpc_encode_reply(XDR *xdr_reply_ctx,
gp_rpc_accept_status acc,
gp_rpc_reject_status rej)
{
xdrfn *res_fn;
bool xdrok;
int ret;

Expand All @@ -291,7 +294,8 @@ static int gp_rpc_encode_reply(XDR *xdr_reply_ctx,
return ret;
}

xdrok = gp_xdr_set[proc].res_fn(xdr_reply_ctx, (char *)res);
res_fn = gp_xdr_set[proc].res_fn;
xdrok = res_fn(xdr_reply_ctx, res);

if (!xdrok) {
return gp_rpc_encode_reply_header(xdr_reply_ctx, xid, EINVAL,
Expand Down

0 comments on commit 5db93aa

Please sign in to comment.