git: 95a3301ce144 - main - rpcinfo: Fix residual warnings and bump WARNS

Mark Johnston <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src,gmane.os.freebsd.current.scm
Message-ID <[email protected]>
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=95a3301ce144aecce5de88fb4e2905c440533fb8

commit 95a3301ce144aecce5de88fb4e2905c440533fb8
Author:     Mark Johnston <[email protected]>
AuthorDate: 2026-07-27 19:00:49 +0000
Commit:     Mark Johnston <[email protected]>
CommitDate: 2026-07-27 23:03:16 +0000

    rpcinfo: Fix residual warnings and bump WARNS
    
    Reviewed by:    emaste
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D58442
---
 usr.bin/rpcinfo/Makefile  |  2 --
 usr.bin/rpcinfo/rpcinfo.c | 29 +++++++++++++++--------------
 2 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/usr.bin/rpcinfo/Makefile b/usr.bin/rpcinfo/Makefile
index a55485e4f718..ffe593401397 100644
--- a/usr.bin/rpcinfo/Makefile
+++ b/usr.bin/rpcinfo/Makefile
@@ -4,6 +4,4 @@ MAN=	rpcinfo.8
 
 CFLAGS+= -DPORTMAP
 
-WARNS?=	2
-
 .include <bsd.prog.mk>
diff --git a/usr.bin/rpcinfo/rpcinfo.c b/usr.bin/rpcinfo/rpcinfo.c
index 70d632fb9227..15c4ca4721b1 100644
--- a/usr.bin/rpcinfo/rpcinfo.c
+++ b/usr.bin/rpcinfo/rpcinfo.c
@@ -79,7 +79,7 @@
 #define MAXHOSTLEN 256
 #define	MIN_VERS	((u_long) 0)
 #define	MAX_VERS	((u_long) 4294967295UL)
-#define	UNKNOWN		"unknown"
+static char unknown[] = "unknown";
 
 /*
  * Functions to be performed.
@@ -103,7 +103,7 @@ struct netidlist {
 };
 
 struct verslist {
-	int vers;
+	rpcvers_t vers;
 	struct verslist *next;
 };
 
@@ -145,8 +145,8 @@ static void	print_getaddrstat(int, rpcb_stat *);
 static void	usage(void);
 static u_long	getprognum(char *);
 static u_long	getvers(char *);
-static char	*spaces(int);
-static bool_t	add_version(struct rpcbdump_short *, u_long);
+static const char *spaces(size_t);
+static bool_t	add_version(struct rpcbdump_short *, rpcvers_t);
 static bool_t	add_netid(struct rpcbdump_short *, char *);
 
 int
@@ -597,13 +597,13 @@ reply_proc(char *res __unused, const struct netbuf *who,
 	struct sockaddr *sa = (struct sockaddr *)who->buf;
 
 	if (getnameinfo(sa, sa->sa_len, hostbuf, NI_MAXHOST, NULL, 0, 0)) {
-		hostname = UNKNOWN;
+		hostname = unknown;
 	} else {
 		hostname = hostbuf;
 	}
 	uaddr = taddr2uaddr(nconf, who);
 	if (uaddr == NULL) {
-		printf("%s\t%s\n", UNKNOWN, hostname);
+		printf("%s\t%s\n", unknown, hostname);
 	} else {
 		printf("%s\t%s\n", uaddr, hostname);
 		free((char *)uaddr);
@@ -630,7 +630,7 @@ brdcst(int argc, char **argv)
 }
 
 static bool_t
-add_version(struct rpcbdump_short *rs, u_long vers)
+add_version(struct rpcbdump_short *rs, rpcvers_t vers)
 {
 	struct verslist *vl;
 
@@ -769,7 +769,7 @@ rpcbdump(int dumptype, char *netid, int argc, char **argv)
 			    }
 			    if (list->rpcb_map.r_netid == NULL)
 				    goto error;
-			    list->rpcb_map.r_owner = UNKNOWN;
+			    list->rpcb_map.r_owner = unknown;
 			    low = pmaphead->pml_map.pm_port & 0xff;
 			    high = (pmaphead->pml_map.pm_port >> 8) & 0xff;
 			    (void)asprintf(&list->rpcb_map.r_addr,
@@ -977,7 +977,8 @@ rpcbgetstat(int argc, char **argv)
 	struct timeval minutetimeout;
 	register CLIENT *client;
 	char *host;
-	int i, j;
+	unsigned int i;
+	int j;
 	rpcbs_addrlist *pa;
 	rpcbs_rmtcalllist *pr;
 	int cnt, flen;
@@ -1653,7 +1654,7 @@ print_rmtcallstat(int rtype, rpcb_stat *infp)
 }
 
 static void
-print_getaddrstat(int rtype, rpcb_stat *infp)
+print_getaddrstat(int rtype __unused, rpcb_stat *infp)
 {
 	rpcbs_addrlist_ptr al;
 	register struct rpcent *rpc;
@@ -1671,14 +1672,14 @@ print_getaddrstat(int rtype, rpcb_stat *infp)
 	}
 }
 
-static char *
-spaces(int howmany)
+static const char *
+spaces(size_t howmany)
 {
 	static char space_array[] =		/* 64 spaces */
 	"                                                                ";
 
-	if (howmany <= 0 || howmany > sizeof (space_array)) {
+	if (howmany >= sizeof(space_array)) {
 		return ("");
 	}
-	return (&space_array[sizeof (space_array) - howmany - 1]);
+	return (&space_array[sizeof(space_array) - howmany - 1]);
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.