From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936366AbcISIOs (ORCPT ); Mon, 19 Sep 2016 04:14:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43430 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932580AbcISIOk (ORCPT ); Mon, 19 Sep 2016 04:14:40 -0400 Date: Mon, 19 Sep 2016 10:14:38 +0200 From: Jiri Olsa To: Andi Kleen Cc: acme@kernel.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, Andi Kleen Subject: Re: [PATCH 1/2] perf, tools, list: Print aliases with --raw-dump Message-ID: <20160919081438.GD26906@krava> References: <1474222699-28969-1-git-send-email-andi@firstfloor.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1474222699-28969-1-git-send-email-andi@firstfloor.org> User-Agent: Mutt/1.7.0 (2016-08-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 19 Sep 2016 08:14:40 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Sep 18, 2016 at 11:18:18AM -0700, Andi Kleen wrote: > From: Andi Kleen > > Print aliases like 'cycles' with perf list --raw-dump, so that > they can be completed by perf-completion.sh > > Signed-off-by: Andi Kleen > --- > tools/perf/util/parse-events.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c > index 94846271cb1c..9716c2bc6869 100644 > --- a/tools/perf/util/parse-events.c > +++ b/tools/perf/util/parse-events.c > @@ -2191,13 +2191,21 @@ restart: > > if (!evt_num_known) { > evt_num++; > + if (strlen(syms->alias)) > + evt_num++; > continue; > } > > if (!name_only && strlen(syms->alias)) > snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias); > - else > + else { > + if (strlen(syms->alias)) { > + evt_list[evt_i++] = strdup(syms->alias); why don't you copy syms->alias into name and let the code below do the queue? thanks, jirka > + if (evt_list[evt_i - 1] == NULL) > + goto out_enomem; > + } > strncpy(name, syms->symbol, MAX_NAME_LEN); > + } > > evt_list[evt_i] = strdup(name); > if (evt_list[evt_i] == NULL) > -- > 2.5.5 >