public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Nicholas Mc Guire <der.herr@hofr.at>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Nicholas Mc Guire <hofrat@osadl.org>,
	Lai Jiangshan <laijs@cn.fujitsu.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Josh Triplett <josh@joshtriplett.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC] rcu: change return type to bool
Date: Sun, 24 May 2015 00:41:58 -0700	[thread overview]
Message-ID: <1432453318.2846.16.camel@perches.com> (raw)
In-Reply-To: <20150524072711.GA17508@opentech.at>

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.



  reply	other threads:[~2015-05-24  7:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-23 14:47 [PATCH RFC] rcu: change return type to bool Nicholas Mc Guire
2015-05-23 22:58 ` Steven Rostedt
2015-05-24  7:27   ` Nicholas Mc Guire
2015-05-24  7:41     ` Joe Perches [this message]
2015-05-24  8:10       ` Nicholas Mc Guire
2015-05-24  8:38         ` Joe Perches
2015-05-24  8:46           ` Nicholas Mc Guire
2015-05-26 18:30             ` Paul E. McKenney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1432453318.2846.16.camel@perches.com \
    --to=joe@perches.com \
    --cc=der.herr@hofr.at \
    --cc=hofrat@osadl.org \
    --cc=josh@joshtriplett.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox