lkml.org 
[lkml]   [2020]   [Apr]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 10/10] objtool: Support multiple stack_op per instruction
On Fri, Apr 03, 2020 at 09:01:46AM +0100, Julien Thierry wrote:
>
>
> On 4/2/20 6:54 PM, Josh Poimboeuf wrote:
> > On Fri, Mar 27, 2020 at 03:28:47PM +0000, Julien Thierry wrote:
> > > @@ -127,6 +129,10 @@ int arch_decode_instruction(struct elf *elf, struct section *sec,
> > > if (insn.sib.nbytes)
> > > sib = insn.sib.bytes[0];
> > > + op = calloc(1, sizeof(*op));
> > > + if (!op)
> > > + return -1;
> > > +
> >
> > Why not malloc()?
> >
>
> It's just that previsously, stack_op was part of the instruction structure
> and was initialized to all 0 in decode_instructions(). Now that it's created
> here, I assumed it would be better to have the same thing here and
> initialized the new stack_op to all 0.
>
> Do you prefer to have an explicit malloc() + memset()?

Maybe just add a comment that calloc() is equivalent to malloc() +
memset() zero, for us user-space neophytes :-)

--
Josh

\
 
 \ /
  Last update: 2020-04-03 16:55    [W:0.071 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site