Re: [PATCH 02/25] tracing: Improve "if" macro code generation
From: Steven Rostedt
Date: Thu May 09 2019 - 09:02:13 EST
On Wed, 20 Mar 2019 10:26:17 -0700
Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> On Wed, Mar 20, 2019 at 4:17 AM David Laight <David.Laight@xxxxxxxxxx> wrote:
> >
> > > ______r = !!(cond); \
> >
> > Is that (or maybe just the !!) needed any more??
>
> It is, because the 'cond' expression might not be an int, it could be
> a test for a pointer being non-NULL, or an u64 being non-zero, and not
> having the "!!" would mean that you'd get a warning or drop bits when
> assigning to 'int'.
>
> And you do need the new temporary variable to avoid double evaluation
> the way that code is written.
>
> That said, I do think the code is really ugly. We could:
>
> - avoid the temporary by just simplifying things.
>
> - do the '!!' just once in the parent macro.
>
> - Steven has this crazy model of "more underscores are better". They
> aren't. They don't help if things nest anyway, but what does help is
> meaningful names. Both when things don't nest, and when looking at
> generated asm files.
>
> - ,, and finally, what _is_ better is to chop things up so that they
> are smaller and make each macro do only one thing
>
> So maybe do the patch something like the attached instead? Completely
> untested, but it looks sane to me.
>
Linus,
This patch works. Can I get your Signed-off-by for it?
-- Steve