From: kn Date: Mon, 21 Nov 2022 22:50:07 +0000 (+0000) Subject: Replace manual loop and duplicate RB_NEXT with RB_FOREACH X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=408def72c86da2d640648ebfe32644a317bf86de;p=openbsd Replace manual loop and duplicate RB_NEXT with RB_FOREACH The loop begins with saving a pointer to the next interface, does work and then gets the same next interface again, for nothing. Switch to the elsewhere consistently used RB_FOREACH helper. OK sashan --- diff --git a/sys/net/pf_if.c b/sys/net/pf_if.c index 0ed3edccb35..2f888b8d7b7 100644 --- a/sys/net/pf_if.c +++ b/sys/net/pf_if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf_if.c,v 1.107 2022/11/21 07:27:10 sashan Exp $ */ +/* $OpenBSD: pf_if.c,v 1.108 2022/11/21 22:50:07 kn Exp $ */ /* * Copyright 2005 Henning Brauer @@ -759,11 +759,10 @@ pfi_update_status(const char *name, struct pf_status *pfs) void pfi_get_ifaces(const char *name, struct pfi_kif *buf, int *size) { - struct pfi_kif *p, *nextp; + struct pfi_kif *p; int n = 0; - for (p = RB_MIN(pfi_ifhead, &pfi_ifs); p; p = nextp) { - nextp = RB_NEXT(pfi_ifhead, &pfi_ifs, p); + RB_FOREACH(p, pfi_ifhead, &pfi_ifs) { if (pfi_skip_if(name, p)) continue; if (*size <= ++n) @@ -771,7 +770,6 @@ pfi_get_ifaces(const char *name, struct pfi_kif *buf, int *size) if (!p->pfik_tzero) p->pfik_tzero = gettime(); memcpy(buf++, p, sizeof(*buf)); - nextp = RB_NEXT(pfi_ifhead, &pfi_ifs, p); } *size = n; }