lkml.org 
[lkml]   [2019]   [May]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2] rcu: Don't return a value from rcu_assign_pointer()
From
Date
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)

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



\
 
 \ /
  Last update: 2019-05-27 19:58    [W:0.139 / U:0.332 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site