From e2ce1059b0b3d032aa07cc51c24d28ec498feb5f Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Wed, 20 May 2020 11:20:11 -0700 Subject: [PATCH] perf metricgroup: Remove unnecessary ',' from events Remove unnecessary commas from events before they are parsed. This avoids ',' being echoed by parse-events.l. Signed-off-by: Ian Rogers Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: Andrii Nakryiko Cc: Cong Wang Cc: Jin Yao Cc: John Garry Cc: Kajol Jain Cc: Kan Liang Cc: Kim Phillips Cc: Mark Rutland Cc: Namhyung Kim Cc: Paul Clarke Cc: Peter Zijlstra Cc: Song Liu Cc: Srikar Dronamraju Cc: Stephane Eranian Cc: Vince Weaver Cc: bpf@vger.kernel.org Cc: netdev@vger.kernel.org Link: http://lore.kernel.org/lkml/20200520182011.32236-8-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/metricgroup.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 8f8f527eb75f..9e21aa767e41 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -504,9 +504,14 @@ static void metricgroup__add_metric_non_group(struct strbuf *events, { struct hashmap_entry *cur; size_t bkt; + bool first = true; - hashmap__for_each_entry((&ctx->ids), cur, bkt) - strbuf_addf(events, ",%s", (const char *)cur->key); + hashmap__for_each_entry((&ctx->ids), cur, bkt) { + if (!first) + strbuf_addf(events, ","); + strbuf_addf(events, "%s", (const char *)cur->key); + first = false; + } } static void metricgroup___watchdog_constraint_hint(const char *name, bool foot)