public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.ibm.com>
To: Joe Perches <joe@perches.com>
Cc: Andrea Parri <andrea.parri@amarulasolutions.com>,
	linux-kernel@vger.kernel.org,
	Josh Triplett <josh@joshtriplett.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	Joel Fernandes <joel@joelfernandes.org>,
	rcu@vger.kernel.org, Peter Zijlstra <peterz@infradead.org>,
	Will Deacon <will.deacon@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Matthew Wilcox <willy@infradead.org>,
	Sasha Levin <sashal@kernel.org>,
	apw@canonical.com
Subject: Re: [PATCH v2] rcu: Don't return a value from rcu_assign_pointer()
Date: Mon, 27 May 2019 12:23:56 -0700	[thread overview]
Message-ID: <20190527192356.GN28207@linux.ibm.com> (raw)
In-Reply-To: <475b18e78ba7e04363fe002315f75d2ce35496f9.camel@perches.com>

On Mon, May 27, 2019 at 10:57:52AM -0700, Joe Perches wrote:
> On Mon, 2019-05-27 at 10:49 -0700, Paul E. McKenney wrote:
> > On Mon, May 27, 2019 at 10:21:22AM -0700, Joe Perches wrote:
> > > On Mon, 2019-05-27 at 09:10 -0700, Paul E. McKenney wrote:
> > > > On Mon, May 27, 2019 at 10:49:57AM +0200, Andrea Parri wrote:
> > > > > Quoting Paul [1]:
> > > > > 
> > > > >   "Given that a quick (and perhaps error-prone) search of the uses
> > > > >    of rcu_assign_pointer() in v5.1 didn't find a single use of the
> > > > >    return value, let's please instead change the documentation and
> > > > >    implementation to eliminate the return value."
> > > > > 
> > > > > [1] https://lkml.kernel.org/r/20190523135013.GL28207@linux.ibm.com
> > > > 
> > > > Queued, thank you!
> > > > 
> > > > Adding the checkpatch maintainers on CC as well.  The "do { } while
> > > > (0)" prevents the return value from being used, by design.  Given the
> > > > checkpatch complaint, is there some better way to achieve this?
> > > 
> > > Not sure what the checkpatch complaint is here.
> > 
> > Checkpatch seems to want at least two statements in each
> > "do { } while (0)" macro definition:
> > 
> > WARNING: Single statement macros should not use a do {} while (0) loop
> > 
> > > Reading the link above, there seems to be a compiler warning.
> > 
> > The compiler warning is a theoretical issue that is being fixed by this
> > patch, and the patch is giving the checkpatch warning.
> > 
> > > Perhaps a statement expression macro with no return value?
> > > 
> > > #define rcu_assign_pointer(p, v)	({ (p) = (v); ; })
> > 
> > This is at best an acquired taste for me...
> 
> Another ugly possibility could be:
> 
> #define rcu_assign_pointer(p, v) do {if (1) (p) = (v); } while (0)

And, not to be left out, another ugly possibility might be:

#define rcu_assign_pointer(p, v) ((void)((p) = (v)))

> Possibly the best option would be to ignore checkpatch here
> and just add a comment above the use.

Works for me!

							Thanx, Paul


      reply	other threads:[~2019-05-27 19:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-27  8:49 [PATCH v2] rcu: Don't return a value from rcu_assign_pointer() Andrea Parri
2019-05-27 16:10 ` Paul E. McKenney
2019-05-27 17:21   ` Joe Perches
2019-05-27 17:49     ` Paul E. McKenney
2019-05-27 17:57       ` Joe Perches
2019-05-27 19:23         ` Paul E. McKenney [this message]

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=20190527192356.GN28207@linux.ibm.com \
    --to=paulmck@linux.ibm.com \
    --cc=andrea.parri@amarulasolutions.com \
    --cc=apw@canonical.com \
    --cc=jiangshanlai@gmail.com \
    --cc=joe@perches.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=peterz@infradead.org \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=sashal@kernel.org \
    --cc=will.deacon@arm.com \
    --cc=willy@infradead.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