diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 54a4c152edb3..6896e739ae4e 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -1044,8 +1044,7 @@ static void nsec_printout(int id, int nr, struct perf_evsel *evsel, double avg) fprintf(output, fmt_n, name); - if (evsel->cgrp) - fprintf(output, "%s%s", csv_sep, evsel->cgrp->name); + fprintf(output, "%s%s", csv_sep, evsel->cgrp ? evsel->cgrp->name : ""); } static int first_shadow_cpu(struct perf_evsel *evsel, int id) @@ -1092,12 +1091,13 @@ static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg) if (evsel->unit) fprintf(output, "%-*s%s", csv_output ? 0 : unit_width, - evsel->unit, csv_sep); + evsel->unit ? evsel->unit : "", csv_sep); + else + fprintf(output, "%s", csv_sep); fprintf(output, "%-*s", csv_output ? 0 : 25, perf_evsel__name(evsel)); - if (evsel->cgrp) - fprintf(output, "%s%s", csv_sep, evsel->cgrp->name); + fprintf(output, "%s%s", csv_sep, evsel->cgrp ? evsel->cgrp->name : ""); } static void printout(int id, int nr, struct perf_evsel *counter, double uval, @@ -1163,9 +1163,8 @@ static void printout(int id, int nr, struct perf_evsel *counter, double uval, csv_output ? 0 : -25, perf_evsel__name(counter)); - if (counter->cgrp) - fprintf(stat_config.output, "%s%s", - csv_sep, counter->cgrp->name); + fprintf(stat_config.output, "%s%s", csv_sep, + counter->cgrp ? counter->cgrp->name : ""); if (!csv_output) pm(&os, NULL, NULL, "", 0);