From owner-svn-src-all@freebsd.org Tue Jan 17 20:31:42 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 81435CB40EC; Tue, 17 Jan 2017 20:31:42 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citapm.icyb.net.ua (citapm.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 0AC561A61; Tue, 17 Jan 2017 20:31:37 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citapm.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id WAA03181; Tue, 17 Jan 2017 22:31:30 +0200 (EET) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1cTaPh-000PJF-Ju; Tue, 17 Jan 2017 22:31:29 +0200 Subject: Re: svn commit: r312236 - head/sys/net80211 To: Adrian Chadd , Ian Lepore References: <201701151949.v0FJnl2h027169@repo.freebsd.org> <1484510213.86335.110.camel@freebsd.org> Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" From: Andriy Gapon Message-ID: <0c2cb416-9d33-3d50-95be-c84154c11797@FreeBSD.org> Date: Tue, 17 Jan 2017 22:30:07 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 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: Tue, 17 Jan 2017 20:31:42 -0000 On 15/01/2017 22:43, Adrian Chadd wrote: > On 15 January 2017 at 11:56, Ian Lepore wrote: > >> >> What is the point of the !! in these macros? The expressions already >> have boolean type (even in C++ where it matters) due to the ==. >> Removing the !! would also make one level of parens redundant. > > It's just a habit i picked up from linux-land. That way it really is > only 1 or 0, so things like debugging output and such make easier > sense. Well, that habit is useful when applied to results of bit-wise operations. It does nothing but obfuscating the code when applied to results of logical operations. Which is the case here. And even with the bit-wise operation we have a FreeBSD idiom of comparing the result with zero using != 0. More verbose, but also more stylish. > It's also fixed a handful of bugs in the past (but I can't think of > exact cases right now) - primarily where other code expected 1 or 0 > (for things like shifts into protocol fields) and the macro returns 0 > or ${LARGEVAL}. -- Andriy Gapon