git: e4253ae822ec - main - rpc.rstatd/rwalld: Use more accurate function pointer types.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 18 Apr 2023 18:31:28 UTC
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=e4253ae822ec819a6258b98023c90378b894896a commit e4253ae822ec819a6258b98023c90378b894896a Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2023-04-18 18:21:50 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2023-04-18 18:21:50 +0000 rpc.rstatd/rwalld: Use more accurate function pointer types. Reviewed by: zlei, rmacklem Differential Revision: https://reviews.freebsd.org/D39521 --- libexec/rpc.rstatd/rstat_proc.c | 33 +++++++++++++++++---------------- libexec/rpc.rwalld/rwalld.c | 19 ++++++++++--------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/libexec/rpc.rstatd/rstat_proc.c b/libexec/rpc.rstatd/rstat_proc.c index f0f2ffd65b57..1f1bb7cf4048 100644 --- a/libexec/rpc.rstatd/rstat_proc.c +++ b/libexec/rpc.rstatd/rstat_proc.c @@ -406,9 +406,10 @@ rstat_service(struct svc_req *rqstp, SVCXPRT *transp) union { int fill; } argument; - char *result; - bool_t (*xdr_argument)(), (*xdr_result)(); - char *(*local)(); + void *result; + xdrproc_t xdr_argument, xdr_result; + typedef void *(svc_cb)(void *arg, struct svc_req *rqstp); + svc_cb *local; switch (rqstp->rq_proc) { case NULLPROC: @@ -416,17 +417,17 @@ rstat_service(struct svc_req *rqstp, SVCXPRT *transp) goto leave; case RSTATPROC_STATS: - xdr_argument = xdr_void; - xdr_result = xdr_statstime; + xdr_argument = (xdrproc_t)xdr_void; + xdr_result = (xdrproc_t)xdr_statstime; switch (rqstp->rq_vers) { case RSTATVERS_ORIG: - local = (char *(*)()) rstatproc_stats_1_svc; + local = (svc_cb *)rstatproc_stats_1_svc; break; case RSTATVERS_SWTCH: - local = (char *(*)()) rstatproc_stats_2_svc; + local = (svc_cb *)rstatproc_stats_2_svc; break; case RSTATVERS_TIME: - local = (char *(*)()) rstatproc_stats_3_svc; + local = (svc_cb *)rstatproc_stats_3_svc; break; default: svcerr_progvers(transp, RSTATVERS_ORIG, RSTATVERS_TIME); @@ -436,17 +437,17 @@ rstat_service(struct svc_req *rqstp, SVCXPRT *transp) break; case RSTATPROC_HAVEDISK: - xdr_argument = xdr_void; - xdr_result = xdr_u_int; + xdr_argument = (xdrproc_t)xdr_void; + xdr_result = (xdrproc_t)xdr_u_int; switch (rqstp->rq_vers) { case RSTATVERS_ORIG: - local = (char *(*)()) rstatproc_havedisk_1_svc; + local = (svc_cb *)rstatproc_havedisk_1_svc; break; case RSTATVERS_SWTCH: - local = (char *(*)()) rstatproc_havedisk_2_svc; + local = (svc_cb *)rstatproc_havedisk_2_svc; break; case RSTATVERS_TIME: - local = (char *(*)()) rstatproc_havedisk_3_svc; + local = (svc_cb *)rstatproc_havedisk_3_svc; break; default: svcerr_progvers(transp, RSTATVERS_ORIG, RSTATVERS_TIME); @@ -460,16 +461,16 @@ rstat_service(struct svc_req *rqstp, SVCXPRT *transp) goto leave; } bzero((char *)&argument, sizeof(argument)); - if (!svc_getargs(transp, (xdrproc_t)xdr_argument, &argument)) { + if (!svc_getargs(transp, xdr_argument, &argument)) { svcerr_decode(transp); goto leave; } result = (*local)(&argument, rqstp); if (result != NULL && - !svc_sendreply(transp, (xdrproc_t)xdr_result, result)) { + !svc_sendreply(transp, xdr_result, result)) { svcerr_systemerr(transp); } - if (!svc_freeargs(transp, (xdrproc_t)xdr_argument, &argument)) + if (!svc_freeargs(transp, xdr_argument, &argument)) errx(1, "unable to free arguments"); leave: if (from_inetd) diff --git a/libexec/rpc.rwalld/rwalld.c b/libexec/rpc.rwalld/rwalld.c index 1261b2301277..adde226cfba8 100644 --- a/libexec/rpc.rwalld/rwalld.c +++ b/libexec/rpc.rwalld/rwalld.c @@ -167,9 +167,10 @@ wallprog_1(struct svc_req *rqstp, SVCXPRT *transp) union { char *wallproc_wall_1_arg; } argument; - char *result; - bool_t (*xdr_argument)(), (*xdr_result)(); - char *(*local)(); + void *result; + xdrproc_t xdr_argument, xdr_result; + typedef void *(svc_cb)(void *arg, struct svc_req *rqstp); + svc_cb *local; switch (rqstp->rq_proc) { case NULLPROC: @@ -177,9 +178,9 @@ wallprog_1(struct svc_req *rqstp, SVCXPRT *transp) goto leave; case WALLPROC_WALL: - xdr_argument = xdr_wrapstring; - xdr_result = xdr_void; - local = (char *(*)()) wallproc_wall_1_svc; + xdr_argument = (xdrproc_t)xdr_wrapstring; + xdr_result = (xdrproc_t)xdr_void; + local = (svc_cb *)wallproc_wall_1_svc; break; default: @@ -187,16 +188,16 @@ wallprog_1(struct svc_req *rqstp, SVCXPRT *transp) goto leave; } bzero(&argument, sizeof(argument)); - if (!svc_getargs(transp, (xdrproc_t)xdr_argument, &argument)) { + if (!svc_getargs(transp, xdr_argument, &argument)) { svcerr_decode(transp); goto leave; } result = (*local)(&argument, rqstp); if (result != NULL && - !svc_sendreply(transp, (xdrproc_t)xdr_result, result)) { + !svc_sendreply(transp, xdr_result, result)) { svcerr_systemerr(transp); } - if (!svc_freeargs(transp, (xdrproc_t)xdr_argument, &argument)) { + if (!svc_freeargs(transp, xdr_argument, &argument)) { syslog(LOG_ERR, "unable to free arguments"); exit(1); }