The branch main has been updated by brooks:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=18d47c1856f4ec3f7a2f9a726bba2ebe64d63dd7

commit 18d47c1856f4ec3f7a2f9a726bba2ebe64d63dd7
Author:     Brooks Davis <[email protected]>
AuthorDate: 2026-02-02 21:20:16 +0000
Commit:     Brooks Davis <[email protected]>
CommitDate: 2026-02-02 21:20:16 +0000

    rpc: correct resultproc_t's type
    
    It takes exactly three arguments of known type.
    
    Tweak the types of various resultproc_t functions to match the type (mostly
    added const to struct pointers) allowing us to drop casts.
    
    Effort:         CHERI upstreaming
    Reviewed by:    vangyzen, glebius
    Sponsored by:   DARPA, AFRL
    Differential Revision:  https://reviews.freebsd.org/D54941
---
 contrib/netbsd-tests/lib/libc/rpc/t_rpc.c | 5 +++--
 include/rpc/clnt.h                        | 3 ++-
 lib/libc/rpc/rpc_soc.c                    | 8 +++++---
 usr.bin/rpcinfo/rpcinfo.c                 | 8 +++++---
 4 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c 
b/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c
index 3000f6aec98b..2737151826bf 100644
--- a/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c
+++ b/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c
@@ -39,7 +39,8 @@ __RCSID("$NetBSD: t_rpc.c,v 1.10 2016/08/27 14:36:22 christos 
Exp $");
 #define RPCBPROC_NULL 0
 
 static int
-reply(caddr_t replyp, struct netbuf * raddrp, struct netconfig * nconf)
+reply(caddr_t replyp, const struct netbuf * raddrp,
+    const struct netconfig * nconf)
 {
        char host[NI_MAXHOST];
        struct sockaddr *sock = raddrp->buf;
@@ -244,7 +245,7 @@ allhosts(const char *transp)
 
        clnt_stat = rpc_broadcast(RPCBPROG, RPCBVERS, RPCBPROC_NULL,
            (xdrproc_t)xdr_void, NULL, (xdrproc_t)xdr_void,
-           NULL, (resultproc_t)reply, transp);
+           NULL, reply, transp);
        if (clnt_stat != RPC_SUCCESS && clnt_stat != RPC_TIMEDOUT)
                ERRX(EXIT_FAILURE, "%s", clnt_sperrno(clnt_stat));
 }
diff --git a/include/rpc/clnt.h b/include/rpc/clnt.h
index eb5e1f5b350f..d7b3e2beb8c0 100644
--- a/include/rpc/clnt.h
+++ b/include/rpc/clnt.h
@@ -514,7 +514,8 @@ __END_DECLS
  *     const char              *nettype;       -- Transport type
  */
 
-typedef bool_t (*resultproc_t)(caddr_t, ...);
+typedef bool_t (*resultproc_t)(caddr_t, const struct netbuf *,
+                              const struct netconfig *);
 
 __BEGIN_DECLS
 extern enum clnt_stat rpc_broadcast(const rpcprog_t, const rpcvers_t,
diff --git a/lib/libc/rpc/rpc_soc.c b/lib/libc/rpc/rpc_soc.c
index e986593badf4..24a19624d366 100644
--- a/lib/libc/rpc/rpc_soc.c
+++ b/lib/libc/rpc/rpc_soc.c
@@ -72,7 +72,8 @@
 static CLIENT *clnt_com_create(struct sockaddr_in *, rpcprog_t, rpcvers_t,
     int *, u_int, u_int, char *);
 static SVCXPRT *svc_com_create(int, u_int, u_int, char *);
-static bool_t rpc_wrap_bcast(char *, struct netbuf *, struct netconfig *);
+static bool_t rpc_wrap_bcast(char *, const struct netbuf *,
+    const struct netconfig *);
 
 /* XXX */
 #define IN4_LOCALHOST_STRING    "127.0.0.1"
@@ -318,7 +319,8 @@ static _Thread_local clnt_broadcast_resultproc_t 
clnt_broadcast_result;
  */
 /* ARGSUSED */
 static bool_t
-rpc_wrap_bcast(char *resultp, struct netbuf *addr, struct netconfig *nconf)
+rpc_wrap_bcast(char *resultp, const struct netbuf *addr,
+    const struct netconfig *nconf)
 /*
  *     char *resultp;          // results of the call
  *     struct netbuf *addr;    // address of the guy who responded
@@ -355,7 +357,7 @@ clnt_broadcast(u_long prog, u_long vers, u_long proc, 
xdrproc_t xargs,
 
        ret = rpc_broadcast((rpcprog_t)prog, (rpcvers_t)vers,
            (rpcproc_t)proc, xargs, argsp, xresults, resultsp,
-           (resultproc_t) rpc_wrap_bcast, "udp");
+           rpc_wrap_bcast, "udp");
 
        clnt_broadcast_result = NULL;
        return (ret);
diff --git a/usr.bin/rpcinfo/rpcinfo.c b/usr.bin/rpcinfo/rpcinfo.c
index 5f2dd4433292..5156dd2db4e0 100644
--- a/usr.bin/rpcinfo/rpcinfo.c
+++ b/usr.bin/rpcinfo/rpcinfo.c
@@ -125,7 +125,8 @@ static void pmapdump(int, char **);
 static void    get_inet_address(struct sockaddr_in *, char *);
 #endif
 
-static bool_t  reply_proc(void *, struct netbuf *, struct netconfig *);
+static bool_t  reply_proc(char *, const struct netbuf *,
+                          const struct netconfig *);
 static void    brdcst(int, char **);
 static void    addrping(char *, char *, int, char **);
 static void    progping(char *, int, char **);
@@ -584,7 +585,8 @@ get_inet_address(struct sockaddr_in *addr, char *host)
 
 /*ARGSUSED*/
 static bool_t
-reply_proc(void *res, struct netbuf *who, struct netconfig *nconf)
+reply_proc(char *res __unused, const struct netbuf *who,
+    const struct netconfig *nconf)
        /* void *res;                   Nothing comes back */
        /* struct netbuf *who;          Who sent us the reply */
        /* struct netconfig *nconf;     On which transport the reply came */
@@ -621,7 +623,7 @@ brdcst(int argc, char **argv)
        vers = getvers(argv[1]);
        rpc_stat = rpc_broadcast(prognum, vers, NULLPROC,
                (xdrproc_t) xdr_void, (char *)NULL, (xdrproc_t) xdr_void,
-               (char *)NULL, (resultproc_t) reply_proc, NULL);
+               (char *)NULL, reply_proc, NULL);
        if ((rpc_stat != RPC_SUCCESS) && (rpc_stat != RPC_TIMEDOUT))
                errx(1, "broadcast failed: %s", clnt_sperrno(rpc_stat));
        exit(0);

Reply via email to