aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2021-07-05 12:02:06 +0000
committerKristof Provost <kp@FreeBSD.org>2021-07-16 08:04:13 +0000
commitdd1ed4d4878765e2f77f01f2d6f35491221a454a (patch)
treebc090e311522a6d4de0583954c2a1d540c6a827d
parentaed0c36c718c2fc0b336544b3ece3d2651456fcf (diff)
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)
-rw-r--r--sys/netpfil/pf/pf_table.c5
1 files 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)