From aa6da8ac5387776b846b71587cb67faca3e7da26 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Wed, 6 Feb 2013 14:57:16 +0900 Subject: [PATCH] --- yaml --- r: 350059 b: refs/heads/master c: 553099857702bb77e541c47bde47f6863834d2e2 h: refs/heads/master i: 350057: 88545346d3b8b741b715d3f5c0658b66876848bb 350055: d336e4f67420ae3b2d167b57177f42e99e422071 v: v3 --- [refs] | 2 +- trunk/tools/perf/builtin-annotate.c | 3 ++- trunk/tools/perf/builtin-diff.c | 4 +++- trunk/tools/perf/builtin-report.c | 3 ++- trunk/tools/perf/builtin-top.c | 3 ++- trunk/tools/perf/tests/hists_link.c | 3 ++- trunk/tools/perf/util/sort.c | 10 ++++++---- trunk/tools/perf/util/sort.h | 2 +- 8 files changed, 19 insertions(+), 11 deletions(-) diff --git a/[refs] b/[refs] index a7ea9fdfa128..1bad6074af12 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 51f27d1440cede5a413d279a20b38767b6f85097 +refs/heads/master: 553099857702bb77e541c47bde47f6863834d2e2 diff --git a/trunk/tools/perf/builtin-annotate.c b/trunk/tools/perf/builtin-annotate.c index dc870cf31b79..95a2ad3f043e 100644 --- a/trunk/tools/perf/builtin-annotate.c +++ b/trunk/tools/perf/builtin-annotate.c @@ -309,7 +309,8 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused) if (symbol__init() < 0) return -1; - setup_sorting(annotate_usage, options); + if (setup_sorting() < 0) + usage_with_options(annotate_usage, options); if (argc) { /* diff --git a/trunk/tools/perf/builtin-diff.c b/trunk/tools/perf/builtin-diff.c index 4af0b580b046..d207a97a2db1 100644 --- a/trunk/tools/perf/builtin-diff.c +++ b/trunk/tools/perf/builtin-diff.c @@ -605,7 +605,9 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused) ui_init(); - setup_sorting(diff_usage, options); + if (setup_sorting() < 0) + usage_with_options(diff_usage, options); + setup_pager(); sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso", NULL); diff --git a/trunk/tools/perf/builtin-report.c b/trunk/tools/perf/builtin-report.c index 91555d4885f4..96b5a7fee4bb 100644 --- a/trunk/tools/perf/builtin-report.c +++ b/trunk/tools/perf/builtin-report.c @@ -751,7 +751,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) } - setup_sorting(report_usage, options); + if (setup_sorting() < 0) + usage_with_options(report_usage, options); /* * Only in the newt browser we are doing integrated annotation, diff --git a/trunk/tools/perf/builtin-top.c b/trunk/tools/perf/builtin-top.c index f561757b1bfa..72f6eb7b4173 100644 --- a/trunk/tools/perf/builtin-top.c +++ b/trunk/tools/perf/builtin-top.c @@ -1129,7 +1129,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) if (sort_order == default_sort_order) sort_order = "dso,symbol"; - setup_sorting(top_usage, options); + if (setup_sorting() < 0) + usage_with_options(top_usage, options); if (top.use_stdio) use_browser = 0; diff --git a/trunk/tools/perf/tests/hists_link.c b/trunk/tools/perf/tests/hists_link.c index 0afd9223bde7..1be64a6c5daf 100644 --- a/trunk/tools/perf/tests/hists_link.c +++ b/trunk/tools/perf/tests/hists_link.c @@ -449,7 +449,8 @@ int test__hists_link(void) goto out; /* default sort order (comm,dso,sym) will be used */ - setup_sorting(NULL, NULL); + if (setup_sorting() < 0) + goto out; machines__init(&machines); diff --git a/trunk/tools/perf/util/sort.c b/trunk/tools/perf/util/sort.c index 03cabe5678d0..d8b48827a17e 100644 --- a/trunk/tools/perf/util/sort.c +++ b/trunk/tools/perf/util/sort.c @@ -565,23 +565,25 @@ int sort_dimension__add(const char *tok) return -ESRCH; } -void setup_sorting(const char * const usagestr[], const struct option *opts) +int setup_sorting(void) { char *tmp, *tok, *str = strdup(sort_order); + int ret = 0; for (tok = strtok_r(str, ", ", &tmp); tok; tok = strtok_r(NULL, ", ", &tmp)) { - int ret = sort_dimension__add(tok); + ret = sort_dimension__add(tok); if (ret == -EINVAL) { error("Invalid --sort key: `%s'", tok); - usage_with_options(usagestr, opts); + break; } else if (ret == -ESRCH) { error("Unknown --sort key: `%s'", tok); - usage_with_options(usagestr, opts); + break; } } free(str); + return ret; } void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list, diff --git a/trunk/tools/perf/util/sort.h b/trunk/tools/perf/util/sort.h index e994ad3e9897..b13e56f6ccbe 100644 --- a/trunk/tools/perf/util/sort.h +++ b/trunk/tools/perf/util/sort.h @@ -160,7 +160,7 @@ struct sort_entry { extern struct sort_entry sort_thread; extern struct list_head hist_entry__sort_list; -void setup_sorting(const char * const usagestr[], const struct option *opts); +int setup_sorting(void); extern int sort_dimension__add(const char *); void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list, const char *list_name, FILE *fp);