From owner-svn-src-all@freebsd.org Thu Jan 25 00:22:36 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 02F39ECF26A; Thu, 25 Jan 2018 00:22:36 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (glebi.us [96.95.210.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 809B27F86C; Thu, 25 Jan 2018 00:22:35 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.15.2/8.15.2) with ESMTPS id w0P0MXdO076117 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 24 Jan 2018 16:22:33 -0800 (PST) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebi.us (8.15.2/8.15.2/Submit) id w0P0MXdG076116; Wed, 24 Jan 2018 16:22:33 -0800 (PST) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@FreeBSD.org using -f Date: Wed, 24 Jan 2018 16:22:33 -0800 From: Gleb Smirnoff To: Kristof Provost 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> References: <201801240429.w0O4THIl059440@repo.freebsd.org> <20180125001310.GJ8113@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Jan 2018 00:22:36 -0000 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