[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-2fbaa39079672bf52a9208ec1263385b48933cc3@git.kernel.org>
Date: Thu, 4 Feb 2016 04:37:33 -0800
From: tip-bot for Jiri Olsa <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: jolsa@...nel.org, acme@...hat.com, linux-kernel@...r.kernel.org,
dsahern@...il.com, a.p.zijlstra@...llo.nl, hpa@...or.com,
mingo@...nel.org, namhyung@...nel.org, tglx@...utronix.de
Subject: [tip:perf/core] perf hists:
Separate sort fields parsing into setup_sort_list function
Commit-ID: 2fbaa39079672bf52a9208ec1263385b48933cc3
Gitweb: http://git.kernel.org/tip/2fbaa39079672bf52a9208ec1263385b48933cc3
Author: Jiri Olsa <jolsa@...nel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:10 +0100
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Wed, 3 Feb 2016 12:24:09 -0300
perf hists: Separate sort fields parsing into setup_sort_list function
Separating sort fields parsing into setup_sort_list function, so it's
separated from sort_order string setup and could be reused later in
following patches.
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
Cc: David Ahern <dsahern@...il.com>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-13-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/util/sort.c | 34 ++++++++++++++++++++++------------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index b5389a5..ab1c21a 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2241,6 +2241,26 @@ static int sort_dimension__add(const char *tok,
return -ESRCH;
}
+static int setup_sort_list(char *str, struct perf_evlist *evlist)
+{
+ char *tmp, *tok;
+ int ret = 0;
+
+ for (tok = strtok_r(str, ", ", &tmp);
+ tok; tok = strtok_r(NULL, ", ", &tmp)) {
+ ret = sort_dimension__add(tok, evlist);
+ if (ret == -EINVAL) {
+ error("Invalid --sort key: `%s'", tok);
+ break;
+ } else if (ret == -ESRCH) {
+ error("Unknown --sort key: `%s'", tok);
+ break;
+ }
+ }
+
+ return ret;
+}
+
static const char *get_default_sort_order(struct perf_evlist *evlist)
{
const char *default_sort_orders[] = {
@@ -2335,7 +2355,7 @@ static char *setup_overhead(char *keys)
static int __setup_sorting(struct perf_evlist *evlist)
{
- char *tmp, *tok, *str;
+ char *str;
const char *sort_keys;
int ret = 0;
@@ -2373,17 +2393,7 @@ static int __setup_sorting(struct perf_evlist *evlist)
}
}
- for (tok = strtok_r(str, ", ", &tmp);
- tok; tok = strtok_r(NULL, ", ", &tmp)) {
- ret = sort_dimension__add(tok, evlist);
- if (ret == -EINVAL) {
- error("Invalid --sort key: `%s'", tok);
- break;
- } else if (ret == -ESRCH) {
- error("Unknown --sort key: `%s'", tok);
- break;
- }
- }
+ ret = setup_sort_list(str, evlist);
free(str);
return ret;
Powered by blists - more mailing lists