Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 Aug 2022 23:17:21 GMT
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 7468304f7b9f - stable/13 - pf: Reduce diffs against OpenBSD in pf_if.c
Message-ID:  <202208282317.27SNHL5b083459@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by emaste:

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

commit 7468304f7b9fe2112f45696258f9b0567666cfcc
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-08-19 21:02:26 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-08-28 23:16:19 +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 02c46db409b6..f572d80c219f 100644
--- a/sys/netpfil/pf/pf_if.c
+++ b/sys/netpfil/pf/pf_if.c
@@ -319,7 +319,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));
@@ -746,7 +746,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)
@@ -804,21 +804,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);
@@ -848,7 +849,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++) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202208282317.27SNHL5b083459>