Date: Fri, 16 Jul 2021 11:53:58 GMT From: Kristof Provost <kp@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: dd1ed4d48787 - stable/12 - pf: Remove unneeded NULL check Message-ID: <202107161153.16GBrw0A016189@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=dd1ed4d4878765e2f77f01f2d6f35491221a454a commit dd1ed4d4878765e2f77f01f2d6f35491221a454a Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2021-07-05 12:02:06 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2021-07-16 08:04:13 +0000 pf: Remove unneeded NULL check pidx is never NULL, and is used unconditionally later on in the function. Add an assertion, as documentation for the requirement to provide an idx pointer. Reported by: clang --analyze MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 8cceacc0f1ee6a77c5f0566b8e6b0f054160fb20) --- sys/netpfil/pf/pf_table.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/netpfil/pf/pf_table.c b/sys/netpfil/pf/pf_table.c index 8dbab5e7bbe1..af7e36c91c08 100644 --- a/sys/netpfil/pf/pf_table.c +++ b/sys/netpfil/pf/pf_table.c @@ -2178,6 +2178,8 @@ pfr_pool_get(struct pfr_ktable *kt, int *pidx, struct pf_addr *counter, struct pfr_kentry *ke, *ke2 = NULL; int idx = -1, use_counter = 0; + MPASS(pidx != NULL); + switch (af) { case AF_INET: uaddr.sin.sin_len = sizeof(struct sockaddr_in); @@ -2195,8 +2197,7 @@ pfr_pool_get(struct pfr_ktable *kt, int *pidx, struct pf_addr *counter, if (!(kt->pfrkt_flags & PFR_TFLAG_ACTIVE)) return (-1); - if (pidx != NULL) - idx = *pidx; + idx = *pidx; if (counter != NULL && idx >= 0) use_counter = 1; if (idx < 0)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107161153.16GBrw0A016189>