From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750929AbbEXHmF (ORCPT ); Sun, 24 May 2015 03:42:05 -0400 Received: from smtprelay0054.hostedemail.com ([216.40.44.54]:60545 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750763AbbEXHmC (ORCPT ); Sun, 24 May 2015 03:42:02 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::,RULES_HIT:41:355:379:541:599:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2692:2693:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3871:3872:3873:3874:4321:5007:6119:6235:6261:7557:7903:10004:10400:10450:10455:10848:11026:11232:11658:11914:12043:12438:12517:12519:12740:13069:13311:13357:14096:14097:19904:19999:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: army19_2e8cd0ed46e54 X-Filterd-Recvd-Size: 2261 Message-ID: <1432453318.2846.16.camel@perches.com> Subject: Re: [PATCH RFC] rcu: change return type to bool From: Joe Perches To: Nicholas Mc Guire Cc: Steven Rostedt , Nicholas Mc Guire , Lai Jiangshan , "Paul E. McKenney" , Josh Triplett , Mathieu Desnoyers , linux-kernel@vger.kernel.org Date: Sun, 24 May 2015 00:41:58 -0700 In-Reply-To: <20150524072711.GA17508@opentech.at> References: <1432392472-20702-1-git-send-email-hofrat@osadl.org> <20150523185820.13b5ad82@gandalf.local.home> <20150524072711.GA17508@opentech.at> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.11-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2015-05-24 at 09:27 +0200, Nicholas Mc Guire wrote: > On Sat, 23 May 2015, Steven Rostedt wrote: [] > > > - return sum; > > > + return !!sum; > > > > Hmm I wonder if gcc is smart enough to do the above without the need > > for !!? That is, will it turn to !! because the return of the function > > is bool, or does gcc complain about it not being bool without the !!? > > Not a criticism of the patch, just a curiosity. > > > gcc will not complain if you assign a unsigned long to a boolean > as I understand it it is a macro and is not doing any type > checking/promotion at all - so anything can be assigned to a bool > without warning (including double and pointers). > The !! will though always make the type compatible with int so it is > a well defined type atleast as far as __builtin_types_compatible_p() > goes, and !! also makes static code checkers happy (that are maybe not > as smart as gcc) and it does make the intent of sum being treated > as boolean here clear. 6.3.1.2 Boolean type When any scalar value is converted to _Bool, the result is 0 if the value compares equal to 0; otherwise, the result is 1.