git: b47001fdeec3 - stable/12 - ipfilter: The SNPRINTF macro doesn't exist, remove it

From: Cy Schubert <cy_at_FreeBSD.org>
Date: Tue, 21 Dec 2021 23:37:56 UTC
The branch stable/12 has been updated by cy:

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

commit b47001fdeec3b146ead52e54518254221cc6653b
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2021-12-13 21:04:34 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2021-12-21 23:37:24 +0000

    ipfilter: The SNPRINTF macro doesn't exist, remove it
    
    (cherry picked from commit 8d2a8d243e1e92c6c88a01f56bb36c24ed1a3486)
---
 sys/contrib/ipfilter/netinet/fil.c         |  8 ------
 sys/contrib/ipfilter/netinet/ip_ftp_pxy.c  | 45 ------------------------------
 sys/contrib/ipfilter/netinet/ip_htable.c   |  4 ---
 sys/contrib/ipfilter/netinet/ip_irc_pxy.c  |  4 ---
 sys/contrib/ipfilter/netinet/ip_lookup.c   |  4 ---
 sys/contrib/ipfilter/netinet/ip_pool.c     |  8 ------
 sys/contrib/ipfilter/netinet/ip_rpcb_pxy.c | 12 --------
 7 files changed, 85 deletions(-)

diff --git a/sys/contrib/ipfilter/netinet/fil.c b/sys/contrib/ipfilter/netinet/fil.c
index 09b4c27a1cb4..7737e2a910bb 100644
--- a/sys/contrib/ipfilter/netinet/fil.c
+++ b/sys/contrib/ipfilter/netinet/fil.c
@@ -5611,11 +5611,7 @@ ipf_grpmapinit(softc, fr)
 	char name[FR_GROUPLEN];
 	iphtable_t *iph;
 
-#if defined(SNPRINTF) && defined(_KERNEL)
-	SNPRINTF(name, sizeof(name), "%d", fr->fr_arg);
-#else
 	(void) sprintf(name, "%d", fr->fr_arg);
-#endif
 	iph = ipf_lookup_find_htable(softc, IPL_LOGIPF, name);
 	if (iph == NULL) {
 		IPFERROR(38);
@@ -6172,11 +6168,7 @@ ipf_getifname(ifp, buffer)
 	unit = ifp->if_unit;
 	space = LIFNAMSIZ - (s - buffer);
 	if ((space > 0) && (unit >= 0)) {
-#  if defined(SNPRINTF) && defined(_KERNEL)
-		SNPRINTF(temp, sizeof(temp), "%d", unit);
-#  else
 		(void) sprintf(temp, "%d", unit);
-#  endif
 		(void) strncpy(s, temp, space);
 	}
 # endif
diff --git a/sys/contrib/ipfilter/netinet/ip_ftp_pxy.c b/sys/contrib/ipfilter/netinet/ip_ftp_pxy.c
index a495292687d9..9783d2dd39a7 100644
--- a/sys/contrib/ipfilter/netinet/ip_ftp_pxy.c
+++ b/sys/contrib/ipfilter/netinet/ip_ftp_pxy.c
@@ -403,14 +403,8 @@ ipf_p_ftp_port(softf, fin, ip, nat, ftp, dlen)
 	a4 = a1 & 0xff;
 	a1 >>= 24;
 	olen = s - f->ftps_rptr;
-	/* DO NOT change this to snprintf! */
-#if defined(SNPRINTF) && defined(_KERNEL)
-	SNPRINTF(newbuf, sizeof(newbuf), "%s %u,%u,%u,%u,%u,%u\r\n",
-		 "PORT", a1, a2, a3, a4, a5, a6);
-#else
 	(void) sprintf(newbuf, "%s %u,%u,%u,%u,%u,%u\r\n",
 		       "PORT", a1, a2, a3, a4, a5, a6);
-#endif
 
 	nlen = strlen(newbuf);
 	inc = nlen - olen;
@@ -834,15 +828,9 @@ ipf_p_ftp_pasv(softf, fin, ip, nat, ftp, dlen)
 	a4 = a1 & 0xff;
 	a1 >>= 24;
 
-#if defined(SNPRINTF) && defined(_KERNEL)
-	SNPRINTF(newbuf, sizeof(newbuf), "%s %s%u,%u,%u,%u,%u,%u%s\r\n",
-		"227 Entering Passive Mode", brackets[0], a1, a2, a3, a4,
-		a5, a6, brackets[1]);
-#else
 	(void) sprintf(newbuf, "%s %s%u,%u,%u,%u,%u,%u%s\r\n",
 		"227 Entering Passive Mode", brackets[0], a1, a2, a3, a4,
 		a5, a6, brackets[1]);
-#endif
 	return ipf_p_ftp_pasvreply(softf, fin, ip, nat, ftp, (a5 << 8 | a6),
 				   newbuf, s);
 }
@@ -1849,14 +1837,9 @@ ipf_p_ftp_eprt4(softf, fin, ip, nat, ftp, dlen)
 	 * sense to preserve whatever character is being used by the systems
 	 * involved in the communication.
 	 */
-#if defined(SNPRINTF) && defined(_KERNEL)
-	SNPRINTF(newbuf, sizeof(newbuf), "%s %c1%c%u.%u.%u.%u%c%u%c\r\n",
-		 "EPRT", delim, delim, a1, a2, a3, a4, delim, port, delim);
-#else
 	(void) sprintf(newbuf, "%s %c1%c%u.%u.%u.%u%c%u%c\r\n",
 		       "EPRT", delim, delim, a1, a2, a3, a4, delim, port,
 			delim);
-#endif
 
 	nlen = strlen(newbuf);
 	inc = nlen - olen;
@@ -1955,13 +1938,8 @@ ipf_p_ftp_epsv(softf, fin, ip, nat, ftp, dlen)
 	}
 	s += 2;
 
-#if defined(SNPRINTF) && defined(_KERNEL)
-	SNPRINTF(newbuf, sizeof(newbuf), "%s (|||%u|)\r\n",
-		 "229 Entering Extended Passive Mode", ap);
-#else
 	(void) sprintf(newbuf, "%s (|||%u|)\r\n",
 		       "229 Entering Extended Passive Mode", ap);
-#endif
 
 	return ipf_p_ftp_pasvreply(softf, fin, ip, nat, ftp, (u_int)ap,
 				   newbuf, s);
@@ -2106,28 +2084,6 @@ ipf_p_ftp_eprt6(softf, fin, ip, nat, ftp, dlen)
 	 */
 	s = newbuf;
 	left = sizeof(newbuf);
-#if defined(SNPRINTF) && defined(_KERNEL)
-	SNPRINTF(newbuf, left, "EPRT %c2%c", delim, delim);
-	left -= strlen(s) + 1;
-	s += strlen(s);
-	a = ntohl(a6->i6[0]);
-	SNPRINTF(s, left, "%x:%x:", a >> 16, a & 0xffff);
-	left -= strlen(s);
-	s += strlen(s);
-	a = ntohl(a6->i6[1]);
-	SNPRINTF(s, left, "%x:%x:", a >> 16, a & 0xffff);
-	left -= strlen(s);
-	s += strlen(s);
-	a = ntohl(a6->i6[2]);
-	SNPRINTF(s, left, "%x:%x:", a >> 16, a & 0xffff);
-	left -= strlen(s);
-	s += strlen(s);
-	a = ntohl(a6->i6[3]);
-	SNPRINTF(s, left, "%x:%x", a >> 16, a & 0xffff);
-	left -= strlen(s);
-	s += strlen(s);
-	SNPRINTF(s, left, "|%d|\r\n", port);
-#else
 	(void) sprintf(s, "EPRT %c2%c", delim, delim);
 	s += strlen(s);
 	a = ntohl(a6->i6[0]);
@@ -2146,7 +2102,6 @@ ipf_p_ftp_eprt6(softf, fin, ip, nat, ftp, dlen)
 	left -= strlen(s);
 	s += strlen(s);
 	sprintf(s, "|%d|\r\n", port);
-#endif
 	nlen = strlen(newbuf);
 	inc = nlen - olen;
 	if ((inc + fin->fin_plen) > 65535) {
diff --git a/sys/contrib/ipfilter/netinet/ip_htable.c b/sys/contrib/ipfilter/netinet/ip_htable.c
index bd1a7136086f..db65c8652be4 100644
--- a/sys/contrib/ipfilter/netinet/ip_htable.c
+++ b/sys/contrib/ipfilter/netinet/ip_htable.c
@@ -325,11 +325,7 @@ ipf_htable_create(softc, arg, op)
 		i = IPHASH_ANON;
 		do {
 			i++;
-#if defined(SNPRINTF) && defined(_KERNEL)
-			SNPRINTF(name, sizeof(name), "%u", i);
-#else
 			(void)sprintf(name, "%u", i);
-#endif
 			for (oiph = softh->ipf_htables[unit + 1]; oiph != NULL;
 			     oiph = oiph->iph_next)
 				if (strncmp(oiph->iph_name, name,
diff --git a/sys/contrib/ipfilter/netinet/ip_irc_pxy.c b/sys/contrib/ipfilter/netinet/ip_irc_pxy.c
index 4446b2100645..a233d24b9a87 100644
--- a/sys/contrib/ipfilter/netinet/ip_irc_pxy.c
+++ b/sys/contrib/ipfilter/netinet/ip_irc_pxy.c
@@ -310,11 +310,7 @@ ipf_p_irc_send(fin, nat)
 	i++;
 	(void) strncpy(newbuf, ctcpbuf, i);
 	/* DO NOT change these! */
-#if defined(SNPRINTF) && defined(KERNEL)
-	SNPRINTF(newbuf, sizeof(newbuf) - i, "%u %u\001\r\n", a1, a5);
-#else
 	(void) sprintf(newbuf, "%u %u\001\r\n", a1, a5);
-#endif
 
 	nlen = strlen(newbuf);
 	inc = nlen - olen;
diff --git a/sys/contrib/ipfilter/netinet/ip_lookup.c b/sys/contrib/ipfilter/netinet/ip_lookup.c
index 66dec84944a1..931d91f4e5f2 100644
--- a/sys/contrib/ipfilter/netinet/ip_lookup.c
+++ b/sys/contrib/ipfilter/netinet/ip_lookup.c
@@ -845,11 +845,7 @@ ipf_lookup_res_num(softc, unit, type, number, funcptr)
 {
 	char name[FR_GROUPLEN];
 
-#if defined(SNPRINTF) && defined(_KERNEL)
-	SNPRINTF(name, sizeof(name), "%u", number);
-#else
 	(void) sprintf(name, "%u", number);
-#endif
 
 	return ipf_lookup_res_name(softc, unit, type, name, funcptr);
 }
diff --git a/sys/contrib/ipfilter/netinet/ip_pool.c b/sys/contrib/ipfilter/netinet/ip_pool.c
index fdd83ebd977f..a890fdf455fc 100644
--- a/sys/contrib/ipfilter/netinet/ip_pool.c
+++ b/sys/contrib/ipfilter/netinet/ip_pool.c
@@ -982,21 +982,13 @@ ipf_pool_create(softc, softp, op)
 		h->ipo_flags |= IPOOL_ANON;
 		poolnum = LOOKUP_ANON;
 
-#if defined(SNPRINTF) && defined(_KERNEL)
-		SNPRINTF(name, sizeof(name), "%x", poolnum);
-#else
 		(void)sprintf(name, "%x", poolnum);
-#endif
 
 		for (p = softp->ipf_pool_list[unit + 1]; p != NULL; ) {
 			if (strncmp(name, p->ipo_name,
 				    sizeof(p->ipo_name)) == 0) {
 				poolnum++;
-#if defined(SNPRINTF) && defined(_KERNEL)
-				SNPRINTF(name, sizeof(name), "%x", poolnum);
-#else
 				(void)sprintf(name, "%x", poolnum);
-#endif
 				p = softp->ipf_pool_list[unit + 1];
 			} else
 				p = p->ipo_next;
diff --git a/sys/contrib/ipfilter/netinet/ip_rpcb_pxy.c b/sys/contrib/ipfilter/netinet/ip_rpcb_pxy.c
index 4c7996e59300..88e300b0625f 100644
--- a/sys/contrib/ipfilter/netinet/ip_rpcb_pxy.c
+++ b/sys/contrib/ipfilter/netinet/ip_rpcb_pxy.c
@@ -789,11 +789,7 @@ ipf_p_rpcb_modreq(fin, nat, rm, m, off)
 
 	/* Form new string. */
 	bzero(uaddr, sizeof(uaddr)); /* Just in case we need padding. */
-#if defined(SNPRINTF) && defined(_KERNEL)
-	SNPRINTF(uaddr, sizeof(uaddr),
-#else
 	(void) sprintf(uaddr,
-#endif
 		       "%u.%u.%u.%u.%u.%u", i[0] & 0xff, i[1] & 0xff,
 		       i[2] & 0xff, i[3] & 0xff, p[0] & 0xff, p[1] & 0xff);
 	len = strlen(uaddr);
@@ -1326,11 +1322,7 @@ ipf_p_rpcb_modv3(fin, nat, rm, m, off)
 
 	/* Form new string. */
 	bzero(uaddr, sizeof(uaddr)); /* Just in case we need padding. */
-#if defined(SNPRINTF) && defined(_KERNEL)
-	SNPRINTF(uaddr, sizeof(uaddr),
-#else
 	(void) sprintf(uaddr,
-#endif
 		       "%u.%u.%u.%u.%u.%u", i[0] & 0xff, i[1] & 0xff,
 		       i[2] & 0xff, i[3] & 0xff, p[0] & 0xff, p[1] & 0xff);
 	len = strlen(uaddr);
@@ -1406,11 +1398,7 @@ ipf_p_rpcb_modv4(fin, nat, rm, m, off)
 		/* Form new string. */
 		bzero(uaddr, sizeof(uaddr)); /* Just in case we need
 						padding. */
-#if defined(SNPRINTF) && defined(_KERNEL)
-		SNPRINTF(uaddr, sizeof(uaddr),
-#else
 		(void) sprintf(uaddr,
-#endif
 			       "%u.%u.%u.%u.%u.%u", i[0] & 0xff,
 			       i[1] & 0xff, i[2] & 0xff, i[3] & 0xff,
 			       p[0] & 0xff, p[1] & 0xff);