Commit 929afa00 authored by Adrian Hunter's avatar Adrian Hunter Committed by Arnaldo Carvalho de Melo

perf time-utils: Make perf_time__parse_for_ranges() more logical

Explicit time ranges never contain a percent sign whereas percentage
ranges always do, so it is possible to call the correct parser.
Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190604130017.31207-18-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 2a8afddc
...@@ -402,6 +402,7 @@ int perf_time__parse_for_ranges(const char *time_str, ...@@ -402,6 +402,7 @@ int perf_time__parse_for_ranges(const char *time_str,
struct perf_time_interval **ranges, struct perf_time_interval **ranges,
int *range_size, int *range_num) int *range_size, int *range_num)
{ {
bool has_percent = strchr(time_str, '%');
struct perf_time_interval *ptime_range; struct perf_time_interval *ptime_range;
int size, num, ret = -EINVAL; int size, num, ret = -EINVAL;
...@@ -409,7 +410,7 @@ int perf_time__parse_for_ranges(const char *time_str, ...@@ -409,7 +410,7 @@ int perf_time__parse_for_ranges(const char *time_str,
if (!ptime_range) if (!ptime_range)
return -ENOMEM; return -ENOMEM;
if (perf_time__parse_str(ptime_range, time_str) != 0) { if (has_percent) {
if (session->evlist->first_sample_time == 0 && if (session->evlist->first_sample_time == 0 &&
session->evlist->last_sample_time == 0) { session->evlist->last_sample_time == 0) {
pr_err("HINT: no first/last sample time found in perf data.\n" pr_err("HINT: no first/last sample time found in perf data.\n"
...@@ -427,6 +428,8 @@ int perf_time__parse_for_ranges(const char *time_str, ...@@ -427,6 +428,8 @@ int perf_time__parse_for_ranges(const char *time_str,
if (num < 0) if (num < 0)
goto error_invalid; goto error_invalid;
} else { } else {
if (perf_time__parse_str(ptime_range, time_str))
goto error_invalid;
num = 1; num = 1;
} }
......
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