On Sat, Jul 25, 2020 at 09:58:13AM -0700, Ian Rogers wrote:

SNIP

> >         ret = parse_events_terms(&terms, t->str);
> >         if (ret) {
> >                 pr_debug("failed to parse terms '%s', err %d\n",
> > diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> > index e88e4c7a2a9a..254f02a7fb0d 100644
> > --- a/tools/perf/util/parse-events.c
> > +++ b/tools/perf/util/parse-events.c
> > @@ -2019,6 +2019,27 @@ static void perf_pmu__parse_init(void)
> >         perf_pmu__parse_cleanup();
> >  }
> >
> > +int perf_pmu__test_parse_init(void)
> > +{
> > +       struct perf_pmu_event_symbol *list;
> > +
> > +       list = malloc(sizeof(*list) * 1);
> > +       if (!list)
> > +               return -ENOMEM;
> > +
> > +       list->type   = PMU_EVENT_SYMBOL;
> > +       list->symbol = strdup("read");
> > +
> > +       if (!list->symbol) {
> > +               free(list);
> > +               return -ENOMEM;
> > +       }
> > +
> > +       perf_pmu_events_list = list;
> > +       perf_pmu_events_list_num = 1;
> > +       return 0;
> > +}
> 
> nit: It's easy to see in the test code why this is necessary, could
> the function be moved there? If not perhaps add a function comment?
> The test in the function name is quite load bearing.

both perf_pmu_events_list/cnt are static and I'd like to keep it that
way, so the function needs to be in here.. I'll add comment explaining
this

jirka

Reply via email to