diff options
| author | Kristof Provost <kp@FreeBSD.org> | 2021-07-05 12:02:06 +0000 |
|---|---|---|
| committer | Kristof Provost <kp@FreeBSD.org> | 2021-07-16 08:04:13 +0000 |
| commit | dd1ed4d4878765e2f77f01f2d6f35491221a454a (patch) | |
| tree | bc090e311522a6d4de0583954c2a1d540c6a827d | |
| parent | aed0c36c718c2fc0b336544b3ece3d2651456fcf (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.c | 5 |
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) |
