Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Jan 2018 16:22:33 -0800
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        Kristof Provost <kp@FreeBSD.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r328313 - head/sys/netpfil/pf
Message-ID:  <20180125002233.GL8113@FreeBSD.org>
In-Reply-To: <F461DD1E-DBA0-4E5B-8725-FE1ED775F9AB@FreeBSD.org>
References:  <201801240429.w0O4THIl059440@repo.freebsd.org> <20180125001310.GJ8113@FreeBSD.org> <F461DD1E-DBA0-4E5B-8725-FE1ED775F9AB@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180125002233.GL8113>