| From e39ff8024bd0599fb7970affe46195cbf1c87e0d Mon Sep 17 00:00:00 2001 |
| From: Adrian Hunter <adrian.hunter@intel.com> |
| Date: Tue, 4 Jun 2019 16:00:15 +0300 |
| Subject: [PATCH] perf time-utils: Make perf_time__parse_for_ranges() more |
| logical |
| |
| commit 929afa0092d0ea6be2fbd0ac087319092595eba6 upstream. |
| |
| 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> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/tools/perf/util/time-utils.c b/tools/perf/util/time-utils.c |
| index 20663a460df3..797dc9e3541b 100644 |
| --- a/tools/perf/util/time-utils.c |
| +++ b/tools/perf/util/time-utils.c |
| @@ -403,6 +403,7 @@ 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; |
| |
| @@ -410,7 +411,7 @@ int perf_time__parse_for_ranges(const char *time_str, |
| 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" |
| @@ -432,6 +433,8 @@ int perf_time__parse_for_ranges(const char *time_str, |
| goto error; |
| } |
| } else { |
| + if (perf_time__parse_str(ptime_range, time_str)) |
| + goto error_invalid; |
| num = 1; |
| } |
| |
| -- |
| 2.7.4 |
| |