svn commit: r328652 - head/sys/netpfil/pf

Kristof Provost kp at FreeBSD.org
Thu Feb 1 07:52:07 UTC 2018


Author: kp
Date: Thu Feb  1 07:52:06 2018
New Revision: 328652
URL: https://svnweb.freebsd.org/changeset/base/328652

Log:
  pf: Avoid warning without INVARIANTS
  
  When INVARIANTS is not set the 'last' variable is not used, which can generate
  compiler warnings.
  If this invariant is ever violated it'd result in a KASSERT failure in
  refcount_release(), so this one is not strictly required.

Modified:
  head/sys/netpfil/pf/pf.c

Modified: head/sys/netpfil/pf/pf.c
==============================================================================
--- head/sys/netpfil/pf/pf.c	Thu Feb  1 05:31:24 2018	(r328651)
+++ head/sys/netpfil/pf/pf.c	Thu Feb  1 07:52:06 2018	(r328652)
@@ -1613,7 +1613,6 @@ int
 pf_unlink_state(struct pf_state *s, u_int flags)
 {
 	struct pf_idhash *ih = &V_pf_idhash[PF_IDHASH(s)];
-	int last;
 
 	if ((flags & PF_ENTER_LOCKED) == 0)
 		PF_HASHROW_LOCK(ih);
@@ -1654,8 +1653,9 @@ pf_unlink_state(struct pf_state *s, u_int flags)
 	PF_HASHROW_UNLOCK(ih);
 
 	pf_detach_state(s);
-	last = refcount_release(&s->refs);
-	KASSERT(last == 0, ("Incorrect state reference count"));
+	/* pf_state_insert() initialises refs to 2, so we can never release the
+	 * last reference here, only in pf_release_state(). */
+	(void)refcount_release(&s->refs);
 
 	return (pf_release_state(s));
 }


More information about the svn-src-all mailing list