Re: [PATCH 11/18] perf metric: Add referenced metrics to hash data

From: Jiri Olsa
Date: Mon Jul 13 2020 - 12:56:24 EST


On Mon, Jul 13, 2020 at 05:27:53PM +0100, John Garry wrote:
> On 12/07/2020 14:26, Jiri Olsa wrote:
> > +int expr__add_ref(struct expr_parse_ctx *ctx, struct metric_ref *ref)
> > +{
> > + struct expr_id_data *data_ptr = NULL, *old_data = NULL;
> > + char *old_key = NULL;
> > + char *name;
> > + int ret;
> > +
> > + data_ptr = zalloc(sizeof(*data_ptr));
> > + if (!data_ptr)
> > + return -ENOMEM;
> > +
> > + name = strdup(ref->metric_name);
> > + if (!name) {
> > + free(data_ptr);
> > + return -ENOMEM;
> > + }
>
> JFYI, this was not compiling for me:
>
> util/expr.c: In function âexpr__add_refâ:
> util/expr.c:84:13: error: implicit declaration of function âzallocâ; did you
> mean âvallocâ? [-Werror=implicit-function-declaration]
> data_ptr = zalloc(sizeof(*data_ptr));
> ^~~~~~
> valloc
> util/expr.c:84:13: error: nested extern declaration of âzallocâ
> [-Werror=nested-externs]
> util/expr.c:84:11: error: assignment to âstruct expr_id_data *â from âintâ
> makes pointer from integer without a cast [-Werror=int-conversion]
> data_ptr = zalloc(sizeof(*data_ptr));
> ^
> LDutil/arm-spe-decoder/perf-in.o
> cc1: all warnings being treated as errors
>
> I think the zalloc.h include is missing.

yea, strange it compiles for me.. I'll add it

thanks,
jirka