perf pmu: Simplify an asprintf error message
authorIan Rogers <irogers@google.com>
Wed, 2 Oct 2024 03:20:04 +0000 (20:20 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Fri, 11 Oct 2024 06:40:32 +0000 (23:40 -0700)
Use ifs rather than ?: to avoid a large compound statement.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20241002032016.333748-2-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/pmu.c

index 8993b5853687b1db29c91f764fc5ded5070503f9..cb2eb2407de51b8f52a26a6dd4b1b35c819c2cd9 100644 (file)
@@ -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;
                }
                /*