Skip to content

Commit

Permalink
perf time-utils: Make perf_time__parse_for_ranges() more logical
Browse files Browse the repository at this point in the history
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: Adrian 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.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Adrian Hunter authored and Arnaldo Carvalho de Melo committed Jun 10, 2019
1 parent 2a8afdd commit 929afa0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tools/perf/util/time-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,14 +402,15 @@ int perf_time__parse_for_ranges(const char *time_str,
struct perf_time_interval **ranges,
int *range_size, int *range_num)
{
bool has_percent = strchr(time_str, '%');
struct perf_time_interval *ptime_range;
int size, num, ret = -EINVAL;

ptime_range = perf_time__range_alloc(time_str, &size);
if (!ptime_range)
return -ENOMEM;

if (perf_time__parse_str(ptime_range, time_str) != 0) {
if (has_percent) {
if (session->evlist->first_sample_time == 0 &&
session->evlist->last_sample_time == 0) {
pr_err("HINT: no first/last sample time found in perf data.\n"
Expand All @@ -427,6 +428,8 @@ int perf_time__parse_for_ranges(const char *time_str,
if (num < 0)
goto error_invalid;
} else {
if (perf_time__parse_str(ptime_range, time_str))
goto error_invalid;
num = 1;
}

Expand Down

0 comments on commit 929afa0

Please sign in to comment.