Re: [PATCH 04/13] perf tests: Add another metric parsing test

Ian Rogers
2020-06-02T20:31:00Z

On Tue, Jun 2, 2020 at 12:08 PM Jiri Olsa <jolsa@redhat.com> wrote:
>
> On Tue, Jun 02, 2020 at 10:58:32AM -0700, Ian Rogers wrote:
>
> SNIP
>
> > > +static int check_parse_fake(const char *id)
> > > +{
> > > + struct parse_events_error error;
> >
> > nit: this reads funny as it isn't clear, without looking at
> > check_parse_id, that error is zero initialized.
>
> right, how about something like below?

Thanks, looks good!
Ian

> thanks,
> jirka
>
>
> ---
> diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
> index d3343827eb4d..c745b6e13cbe 100644
> --- a/tools/perf/tests/pmu-events.c
> +++ b/tools/perf/tests/pmu-events.c
> @@ -403,7 +403,6 @@ static int check_parse_id(const char *id, struct parse_events_error *error,
> evlist = evlist__new();
> if (!evlist)
> return -ENOMEM;
> - memset(error, 0, sizeof(*error));
> ret = parse_events(evlist, id, error, fake_pmu);
> evlist__delete(evlist);
> return ret;
> @@ -411,7 +410,7 @@ static int check_parse_id(const char *id, struct parse_events_error *error,
>
> static int check_parse_cpu(const char *id, bool same_cpu, struct pmu_event *pe)
> {
> - struct parse_events_error error;
> + struct parse_events_error error = { 0 };
>
> int ret = check_parse_id(id, &error, false);
> if (ret && same_cpu) {
> @@ -433,7 +432,7 @@ static int check_parse_cpu(const char *id, bool same_cpu, struct pmu_event *pe)
>
> static int check_parse_fake(const char *id)
> {
> - struct parse_events_error error;
> + struct parse_events_error error = { 0 };
> int ret = check_parse_id(id, &error, true);
>
> free(error.str);
>