Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754262AbbFCKcE (ORCPT ); Wed, 3 Jun 2015 06:32:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45856 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754182AbbFCKbu (ORCPT ); Wed, 3 Jun 2015 06:31:50 -0400 Date: Wed, 3 Jun 2015 12:31:43 +0200 From: Jiri Olsa To: Sukadev Bhattiprolu Cc: mingo@redhat.com, ak@linux.intel.com, Michael Ellerman , Arnaldo Carvalho de Melo , namhyung@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v13 06/14] perf, tools: Support alias descriptions Message-ID: <20150603103143.GH1828@krava.redhat.com> References: <1433265135-20426-1-git-send-email-sukadev@linux.vnet.ibm.com> <1433265135-20426-7-git-send-email-sukadev@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1433265135-20426-7-git-send-email-sukadev@linux.vnet.ibm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2009 Lines: 71 On Tue, Jun 02, 2015 at 10:12:06AM -0700, Sukadev Bhattiprolu wrote: SNIP > @@ -1033,37 +1064,49 @@ void print_pmu_events(const char *event_glob, bool name_only) > event_glob)))) > continue; > > - if (is_cpu && !name_only) > + if (is_cpu && !name_only && !alias->desc) > name = format_alias_or(buf, sizeof(buf), pmu, alias); > > - aliases[j] = strdup(name); > - if (aliases[j] == NULL) > - goto out_enomem; > + aliases[j].name = name; > + if (is_cpu && !name_only && !alias->desc) > + aliases[j].name = format_alias_or(buf, sizeof(buf), > + pmu, alias); > + aliases[j].name = strdup(aliases[j].name); > + /* failure harmless */ yea but we still try to care everywhere.. ;-) we would print "NULL" for name in the code below right? please keep the above pattern: if (aliases[j].name == NULL) goto out_enomem; > + aliases[j].desc = alias->desc; > j++; > } > if (pmu->selectable) { > char *s; > if (asprintf(&s, "%s//", pmu->name) < 0) > goto out_enomem; > - aliases[j] = s; > + aliases[j].name = s; > j++; > } > } > len = j; > - qsort(aliases, len, sizeof(char *), cmp_string); > + qsort(aliases, len, sizeof(struct pair), cmp_pair); > for (j = 0; j < len; j++) { > if (name_only) { > - printf("%s ", aliases[j]); > + printf("%s ", aliases[j].name); > continue; > } > - printf(" %-50s [Kernel PMU event]\n", aliases[j]); > + if (aliases[j].desc) { > + if (numdesc++ == 0) > + printf("\n"); > + printf(" %-50s\n", aliases[j].name); > + printf("%*s", 8, "["); > + wordwrap(aliases[j].desc, 8, columns, 0); > + printf("]\n"); > + } else > + printf(" %-50s [Kernel PMU event]\n", aliases[j].name); > printed++; SNIP -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/