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

From: Arnaldo Carvalho de Melo
Date: Thu Sep 12 2024 - 15:21:13 EST


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@xxxxxxxxxx>
> ---
> 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
>