On Tue, May 12, 2020 at 05:17:29PM -0700, Ian Rogers wrote: SNIP
> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c > index 92bd7fafcce6..71d0290b616a 100644 > --- a/tools/perf/util/pmu.c > +++ b/tools/perf/util/pmu.c > @@ -1056,7 +1056,8 @@ static char *pmu_formats_string(struct list_head > *formats) > * Setup one of config[12] attr members based on the > * user input data - term parameter. > */ > -static int pmu_config_term(struct list_head *formats, > +static int pmu_config_term(const char *pmu_name, > + struct list_head *formats, > struct perf_event_attr *attr, > struct parse_events_term *term, > struct list_head *head_terms, > @@ -1082,16 +1083,24 @@ static int pmu_config_term(struct list_head *formats, > > format = pmu_find_format(formats, term->config); > if (!format) { > - if (verbose > 0) > - printf("Invalid event/parameter '%s'\n", term->config); > + char *pmu_term = pmu_formats_string(formats); > + char *unknown_term; > + char *help_msg; > + > + if (asprintf(&unknown_term, > + "unknown term '%s' for pmu '%s'", > + term->config, pmu_name) < 0) > + unknown_term = strdup("unknown term"); is that really necessary? is asprintf fails, strdup will probably too, and parse_events__handle_error checks on the !str, so we should be fine other than that it looks ok to me thanks, jirka > + help_msg = parse_events_formats_error_string(pmu_term); > if (err) { > - char *pmu_term = pmu_formats_string(formats); > - > parse_events__handle_error(err, term->err_term, > - strdup("unknown term"), > - parse_events_formats_error_string(pmu_term)); > - free(pmu_term); > + unknown_term, > + help_msg); > + } else { > + pr_debug("%s (%s)\n", unknown_term, help_msg); > + free(unknown_term); > } > + free(pmu_term); SNIP