[PATCH v2 01/13] perf pmu: Simplify an asprintf error message

Arnaldo Carvalho de Melo acme at kernel.org
Thu Sep 12 12:18:53 PDT 2024


On Thu, Sep 12, 2024 at 12:03:28PM -0700, Ian Rogers wrote:
> Use ifs rather than ?: to avoid a large compound statement.

Cherry picked this one.

- Arnaldo
 
> Signed-off-by: Ian Rogers <irogers at google.com>
> ---
>  tools/perf/util/pmu.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> index 61bdda01a05a..779db2ac06f0 100644
> --- a/tools/perf/util/pmu.c
> +++ b/tools/perf/util/pmu.c
> @@ -1466,13 +1466,12 @@ static int pmu_config_term(const struct perf_pmu *pmu,
>  		if (err) {
>  			char *err_str;
>  
> -			parse_events_error__handle(err, term->err_val,
> -				asprintf(&err_str,
> -				    "value too big for format (%s), maximum is %llu",
> -				    format->name, (unsigned long long)max_val) < 0
> -				    ? strdup("value too big for format")
> -				    : err_str,
> -				    NULL);
> +			if (asprintf(&err_str,
> +				     "value too big for format (%s), maximum is %llu",
> +				     format->name, (unsigned long long)max_val) < 0) {
> +				err_str = strdup("value too big for format");
> +			}
> +			parse_events_error__handle(err, term->err_val, err_str, /*help=*/NULL);
>  			return -EINVAL;
>  		}
>  		/*
> -- 
> 2.46.0.662.g92d0881bb0-goog
> 



More information about the linux-arm-kernel mailing list