[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LSU.2.21.2004241141240.6175@pobox.suse.cz>
Date: Fri, 24 Apr 2020 11:43:13 +0200 (CEST)
From: Miroslav Benes <mbenes@...e.cz>
To: Peter Zijlstra <peterz@...radead.org>
cc: Alexandre Chartre <alexandre.chartre@...cle.com>,
jpoimboe@...hat.com, linux-kernel@...r.kernel.org,
jthierry@...hat.com, tglx@...utronix.de, x86@...nel.org
Subject: Re: [PATCH 3/8] objtool: Rework allocating stack_ops on decode
On Thu, 23 Apr 2020, Peter Zijlstra wrote:
> On Thu, Apr 23, 2020 at 05:40:38PM +0200, Alexandre Chartre wrote:
> >
> > On 4/23/20 2:47 PM, Peter Zijlstra wrote:
> > > Wrap each stack_op in a macro that allocates and adds it to the list.
> > > This simplifies trying to figure out what to do with the pre-allocated
> > > stack_op at the end.
> > >
> > > Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
> > > ---
> > > tools/objtool/arch/x86/decode.c | 257 +++++++++++++++++++++++-----------------
> > > 1 file changed, 153 insertions(+), 104 deletions(-)
> > >
> > > --- a/tools/objtool/arch/x86/decode.c
> > > +++ b/tools/objtool/arch/x86/decode.c
> > > @@ -77,6 +77,17 @@ unsigned long arch_jump_destination(stru
> > > return insn->offset + insn->len + insn->immediate;
> > > }
> > > +#define PUSH_OP(op) \
> > > +({ \
> > > + list_add_tail(&op->list, ops_list); \
> > > + NULL; \
> > > +})
> > > +
> > > +#define ADD_OP(op) \
> > > + if (!(op = calloc(1, sizeof(*op)))) \
> > > + return -1; \
> > > + else for (; op; op = PUSH_OP(op))
> > > +
> >
> > I would better have a function to alloc+add op instead of weird macros,
> > for example:
>
> I know it'll not make you feel (much) better, but we can write it
> shorter:
>
> +#define ADD_OP(op) \
> + if (!(op = calloc(1, sizeof(*op)))) \
> + return -1; \
> + else for (list_add_tail(&op->list, ops_list); op; op = NULL)
FWIW, I like this version the best.
Miroslav
Powered by blists - more mailing lists