Subject: Re: [PATCH v5 10/10] perf tools: report initial event parsing error

From: Jiri Olsa <[email-masked]>
Date: Wed, 6 Nov 2019 15:24:34 +0100

On Wed, Oct 30, 2019 at 03:34:48PM -0700, Ian Rogers wrote:

SNIP

> +
> +void parse_events_print_error(struct parse_events_error *err,
> +			      const char *event)
> +{
> +	if (!err->num_errors)
> +		return;
> +
> +	__parse_events_print_error(err->idx, err->str, err->help, event);
> +	zfree(&err->str);
> +	zfree(&err->help);
> +
> +	if (err->num_errors > 1) {
> +		fputs("\nInitial error:\n", stderr);
> +		__parse_events_print_error(err->first_idx, err->first_str,
> +					err->first_help, event);
> +		zfree(&err->first_str);
> +		zfree(&err->first_help);
>  	}
>  }
>  
> @@ -2071,7 +2104,9 @@ int parse_events_option(const struct option *opt, const char *str,
>  			int unset __maybe_unused)
>  {
>  	struct evlist *evlist = *(struct evlist **)opt->value;
> -	struct parse_events_error err = { .idx = 0, };
> +	struct parse_events_error err;
> +
> +	bzero(&err, sizeof(err));
>  	int ret = parse_events(evlist, str, &err);

this breaks compilation:

make[3]: Nothing to be done for 'plugins/libtraceevent-dynamic-list'.
util/parse-events.c: In function ‘parse_events_option’:
util/parse-events.c:2110:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
 2110 |  int ret = parse_events(evlist, str, &err);
      |  ^~~

thanks,
jirka