On Tue, Oct 22, 2019 at 05:53:30PM -0700, Ian Rogers wrote: > If event parsing fails the event list is leaked, instead splice the list > onto the out result and let the caller cleanup. > > Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx> > --- > tools/perf/util/parse-events.c | 17 +++++++++++------ > 1 file changed, 11 insertions(+), 6 deletions(-) > > diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c > index 4d42344698b8..a8f8801bd127 100644 > --- a/tools/perf/util/parse-events.c > +++ b/tools/perf/util/parse-events.c > @@ -1962,15 +1962,20 @@ int parse_events(struct evlist *evlist, const char *str, > > ret = parse_events__scanner(str, &parse_state, PE_START_EVENTS); > perf_pmu__parse_cleanup(); > + I dont understand.. is there something on the list in case we fail? > + if (list_empty(&parse_state.list)) { > + WARN_ONCE(true, "WARNING: event parser found nothing\n"); > + return -1; > + } this will display extra warning message for fail case: [jolsa@krava perf]$ ./perf record -e krava ls WARNING: event parser found nothing event syntax error: 'krava' \___ parser error we don't want that jirka > + > + /* > + * Add list to the evlist even with errors to allow callers to clean up. > + */ > + perf_evlist__splice_list_tail(evlist, &parse_state.list); > + > if (!ret) { > struct evsel *last; > > - if (list_empty(&parse_state.list)) { > - WARN_ONCE(true, "WARNING: event parser found nothing\n"); > - return -1; > - } > - > - perf_evlist__splice_list_tail(evlist, &parse_state.list); > evlist->nr_groups += parse_state.nr_groups; > last = evlist__last(evlist); > last->cmdline_group_boundary = true; > -- > 2.23.0.866.gb869b98d4c-goog >