git: c4a32455d9cb - main - pf: remove the use of caddr_t

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Tue, 23 May 2023 14:12:57 UTC
The branch main has been updated by kp:

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

commit c4a32455d9cb7f680964243341cfd0f2448eee64
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2023-05-19 18:56:46 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2023-05-23 14:11:13 +0000

    pf: remove the use of caddr_t
    
    Replace caddr_t with void *, or more accurate types.
    
    Suggested by:   glebius
    Reviewed by:    zlei
    Differential Revision:  https://reviews.freebsd.org/D40186
---
 sys/net/pfvar.h           | 6 +++---
 sys/netpfil/pf/pf_ioctl.c | 4 ++--
 sys/netpfil/pf/pf_norm.c  | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h
index e3e467500b94..4bdfa22b58ab 100644
--- a/sys/net/pfvar.h
+++ b/sys/net/pfvar.h
@@ -1704,7 +1704,7 @@ struct pfioc_state_kill {
 struct pfioc_states {
 	int	ps_len;
 	union {
-		caddr_t			 ps_buf;
+		void			*ps_buf;
 		struct pfsync_state	*ps_states;
 	};
 };
@@ -1713,7 +1713,7 @@ struct pfioc_states_v2 {
 	int		ps_len;
 	uint64_t	ps_req_version;
 	union {
-		caddr_t			 ps_buf;
+		void			*ps_buf;
 		struct pf_state_export	*ps_states;
 	};
 };
@@ -1721,7 +1721,7 @@ struct pfioc_states_v2 {
 struct pfioc_src_nodes {
 	int	psn_len;
 	union {
-		caddr_t		 psn_buf;
+		void		*psn_buf;
 		struct pf_src_node	*psn_src_nodes;
 	};
 };
diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c
index d5cea7d2a215..b71104a77996 100644
--- a/sys/netpfil/pf/pf_ioctl.c
+++ b/sys/netpfil/pf/pf_ioctl.c
@@ -1447,8 +1447,8 @@ pf_setup_pfsync_matching(struct pf_kruleset *rs)
 
 		if (rs->rules[rs_cnt].inactive.rcount) {
 			rs->rules[rs_cnt].inactive.ptr_array =
-			    malloc(sizeof(caddr_t) *
-			    rs->rules[rs_cnt].inactive.rcount,
+			    mallocarray(rs->rules[rs_cnt].inactive.rcount,
+			    sizeof(struct pf_rule **),
 			    M_TEMP, M_NOWAIT);
 
 			if (!rs->rules[rs_cnt].inactive.ptr_array)
diff --git a/sys/netpfil/pf/pf_norm.c b/sys/netpfil/pf/pf_norm.c
index 8b267636751a..a902937c1253 100644
--- a/sys/netpfil/pf/pf_norm.c
+++ b/sys/netpfil/pf/pf_norm.c
@@ -883,7 +883,7 @@ pf_reassemble6(struct mbuf **m0, struct ip6_hdr *ip6, struct ip6_frag *fraghdr,
 	/* Take protocol from first fragment header. */
 	m = m_getptr(m, hdrlen + offsetof(struct ip6_frag, ip6f_nxt), &off);
 	KASSERT(m, ("%s: short mbuf chain", __func__));
-	proto = *(mtod(m, caddr_t) + off);
+	proto = *(mtod(m, uint8_t *) + off);
 	m = *m0;
 
 	/* Delete frag6 header */
@@ -967,7 +967,7 @@ pf_refragment6(struct ifnet *ifp, struct mbuf **m0, struct m_tag *mtag,
 		m = m_getptr(m, extoff + offsetof(struct ip6_ext, ip6e_nxt),
 		    &off);
 		KASSERT((m != NULL), ("pf_refragment6: short mbuf chain"));
-		proto = *(mtod(m, caddr_t) + off);
+		proto = *(mtod(m, uint8_t *) + off);
 		*(mtod(m, char *) + off) = IPPROTO_FRAGMENT;
 		m = *m0;
 	} else {