git: 5720c747b237 - stable/12 - pf: Reduce diffs against OpenBSD in pf_if.c

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Mon, 29 Aug 2022 13:07:06 UTC
The branch stable/12 has been updated by emaste:

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

commit 5720c747b237998e820afdf370eb5eb9c0268221
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-08-19 21:02:26 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-08-29 13:06:03 +0000

    pf: Reduce diffs against OpenBSD in pf_if.c
    
    Use memset instead of bzero, memcpy instead of bcopy, and add some
    optional {}s.
    
    Reviewed by:    kp
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D36267
    
    (cherry picked from commit 6b598e263bebaf6664b64f80f029a6ebcfc2848d)
---
 sys/netpfil/pf/pf_if.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/sys/netpfil/pf/pf_if.c b/sys/netpfil/pf/pf_if.c
index 54ac84365180..55e5e4ccac83 100644
--- a/sys/netpfil/pf/pf_if.c
+++ b/sys/netpfil/pf/pf_if.c
@@ -295,7 +295,7 @@ pfi_kkif_find(const char *kif_name)
 
 	PF_RULES_ASSERT();
 
-	bzero(&s, sizeof(s));
+	memset(&s, 0, sizeof(s));
 	strlcpy(s.pfik_name, kif_name, sizeof(s.pfik_name));
 
 	return (RB_FIND(pfi_ifhead, &V_pfi_ifs, (struct pfi_kkif *)&s));
@@ -732,7 +732,7 @@ pfi_address_add(struct sockaddr *sa, int af, int net)
 	if (af == AF_INET && net > 32)
 		net = 128;
 	p = V_pfi_buffer + V_pfi_buffer_cnt++;
-	bzero(p, sizeof(*p));
+	memset(p, 0, sizeof(*p));
 	p->pfra_af = af;
 	p->pfra_net = net;
 	if (af == AF_INET)
@@ -790,21 +790,22 @@ pfi_update_status(const char *name, struct pf_status *pfs)
 	int			 i, j, k;
 
 	if (pfs) {
-		bzero(pfs->pcounters, sizeof(pfs->pcounters));
-		bzero(pfs->bcounters, sizeof(pfs->bcounters));
+		memset(pfs->pcounters, 0, sizeof(pfs->pcounters));
+		memset(pfs->bcounters, 0, sizeof(pfs->bcounters));
 	}
 
 	strlcpy(key.pfik_name, name, sizeof(key.pfik_name));
 	p = RB_FIND(pfi_ifhead, &V_pfi_ifs, (struct pfi_kkif *)&key);
-	if (p == NULL)
+	if (p == NULL) {
 		return;
+	}
 
 	if (p->pfik_group != NULL) {
-		bcopy(&p->pfik_group->ifg_members, &ifg_members,
+		memcpy(&ifg_members, &p->pfik_group->ifg_members,
 		    sizeof(ifg_members));
 	} else {
 		/* build a temporary list for p only */
-		bzero(&p_member, sizeof(p_member));
+		memset(&p_member, 0, sizeof(p_member));
 		p_member.ifgm_ifp = p->pfik_ifp;
 		CK_STAILQ_INIT(&ifg_members);
 		CK_STAILQ_INSERT_TAIL(&ifg_members, &p_member, ifgm_next);
@@ -834,7 +835,7 @@ static void
 pf_kkif_to_kif(struct pfi_kkif *kkif, struct pfi_kif *kif)
 {
 
-	bzero(kif, sizeof(*kif));
+	memset(kif, 0, sizeof(*kif));
 	strlcpy(kif->pfik_name, kkif->pfik_name, sizeof(kif->pfik_name));
 	for (int i = 0; i < 2; i++) {
 		for (int j = 0; j < 2; j++) {