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

Gleb Smirnoff glebius at FreeBSD.org
Thu Jan 25 00:22:36 UTC 2018


On Thu, Jan 25, 2018 at 11:16:23AM +1100, Kristof Provost wrote:
K> On 25 Jan 2018, at 11:13, Gleb Smirnoff wrote:
K> > On Wed, Jan 24, 2018 at 04:29:17AM +0000, Kristof Provost wrote:
K> > K> Author: kp
K> > K> Date: Wed Jan 24 04:29:16 2018
K> > K> New Revision: 328313
K> > K> URL: https://svnweb.freebsd.org/changeset/base/328313
K> > K>
K> > K> Log:
K> > K>   pf: States have at least two references
K> > K>
K> > K>   pf_unlink_state() releases a reference to the state without 
K> > checking if
K> > K>   this is the last reference. It can't be, because 
K> > pf_state_insert()
K> > K>   initialises it to two. KASSERT() that this is always the case.
K> > K>
K> > K>   CID:	1347140
K> > K>
K> 
K> > K> +	last = refcount_release(&s->refs);
K> > K> +	KASSERT(last == 0, ("Incorrect state reference count"));
K> > K>
K> > K>  	return (pf_release_state(s));
K> > K>  }
K> >
K> > IMHO, we shouldn't emit extra code to please Coverity. We can mark it
K> > as a false positive in the interface. It may make sense to add a 
K> > comment
K> > for a human to explain why return isn't checked here.
K> >
K> I find the KASSERT() to be a good way of verifying that this assumption 
K> is in fact correct.
K> You do have a good point about the comment.

Now Coverity will report you about a write-only variable, if Coverity has
a run with INVARIANTS undefined. There should be a better way for doing
that. I don't see it right now though :)

-- 
Gleb Smirnoff


More information about the svn-src-head mailing list