From owner-svn-src-head@freebsd.org Tue Jun 5 21:07:22 2018 Return-Path: Delivered-To: svn-src-head@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 6266CFF6DE7; Tue, 5 Jun 2018 21:07:22 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from smtp.vangyzen.net (hotblack.vangyzen.net [199.48.133.146]) by mx1.freebsd.org (Postfix) with ESMTP id 0D22C72C5A; Tue, 5 Jun 2018 21:07:21 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from sweettea.beer.town (unknown [76.164.8.130]) by smtp.vangyzen.net (Postfix) with ESMTPSA id 6C4185646B; Tue, 5 Jun 2018 16:07:20 -0500 (CDT) Subject: Re: svn commit: r334669 - head/sys/sys To: Ian Lepore , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201806052034.w55KYBsb096418@repo.freebsd.org> <1528232004.63685.25.camel@freebsd.org> From: Eric van Gyzen Openpgp: preference=signencrypt Message-ID: Date: Tue, 5 Jun 2018 16:07:16 -0500 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1528232004.63685.25.camel@freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jun 2018 21:07:22 -0000 On 06/05/2018 15:53, Ian Lepore wrote: > On Tue, 2018-06-05 at 20:34 +0000, Eric van Gyzen wrote: >> Author: vangyzen >> Date: Tue Jun  5 20:34:11 2018 >> New Revision: 334669 >> URL: https://svnweb.freebsd.org/changeset/base/334669 >> >> Log: >>   Make Coverity more happy with r334545 >>    >>   Coverity complains about: >>    >>    if (((flags) & M_WAITOK) || _malloc_item != NULL) >>    >>   saying: >>    >>    The expression >>    1 /* (2 | 0x100) & 2 */ || _malloc_item != NULL >>    is suspicious because it performs a Boolean operation >>    on a constant other than 0 or 1. >>    >>   Although the code is correct, add "!= 0" to make it slightly >>   more legible and to silence hundreds(?) of Coverity warnings. >>    > > This is a sad sad thing. Treating (bits & flagconstants) as boolean has > a long long history in C. Surely there are literally thousand of > occurrances in freebsd code already, so why did this one get flagged? I agree, and I tend to avoid adding "!= 0" unnecessarily, but I don't feel very strongly about it. This macro is expanded in many locations, so the number of Coverity warnings increased by hundreds in the most recent run. I care about that more than avoiding "!= 0". I don't sprinkle crap all over the code just to appease Coverity, but this one seemed perfectly reasonable. It makes the code slightly more clear and legible for some readers, and I imagine it doesn't hurt the others. Yes, there are probably many old occurrences of this, and there might be many old corresponding warnings, but I tend to focus on the recently added ones, just because they're more likely relevant. /me opens the static analysis can of worms...again Eric