Commit 6d3375ef authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf hists: Separate output fields parsing into setup_output_list function

Separating output fields parsing into setup_output_list function, so
it's separated from field_order string setup and could be reused later
in following patches.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-14-git-send-email-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 2fbaa390
...@@ -2535,6 +2535,26 @@ static int output_field_add(char *tok) ...@@ -2535,6 +2535,26 @@ static int output_field_add(char *tok)
return -ESRCH; return -ESRCH;
} }
static int setup_output_list(char *str)
{
char *tmp, *tok;
int ret = 0;
for (tok = strtok_r(str, ", ", &tmp);
tok; tok = strtok_r(NULL, ", ", &tmp)) {
ret = output_field_add(tok);
if (ret == -EINVAL) {
error("Invalid --fields key: `%s'", tok);
break;
} else if (ret == -ESRCH) {
error("Unknown --fields key: `%s'", tok);
break;
}
}
return ret;
}
static void reset_dimensions(void) static void reset_dimensions(void)
{ {
unsigned int i; unsigned int i;
...@@ -2559,7 +2579,7 @@ bool is_strict_order(const char *order) ...@@ -2559,7 +2579,7 @@ bool is_strict_order(const char *order)
static int __setup_output_field(void) static int __setup_output_field(void)
{ {
char *tmp, *tok, *str, *strp; char *str, *strp;
int ret = -EINVAL; int ret = -EINVAL;
if (field_order == NULL) if (field_order == NULL)
...@@ -2579,17 +2599,7 @@ static int __setup_output_field(void) ...@@ -2579,17 +2599,7 @@ static int __setup_output_field(void)
goto out; goto out;
} }
for (tok = strtok_r(strp, ", ", &tmp); ret = setup_output_list(strp);
tok; tok = strtok_r(NULL, ", ", &tmp)) {
ret = output_field_add(tok);
if (ret == -EINVAL) {
error("Invalid --fields key: `%s'", tok);
break;
} else if (ret == -ESRCH) {
error("Unknown --fields key: `%s'", tok);
break;
}
}
out: out:
free(str); free(str);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment