perf util: Improve error checking for time percent input
authorJin Yao <yao.jin@linux.intel.com>
Wed, 10 Jan 2018 15:00:28 +0000 (23:00 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 17 Jan 2018 13:23:35 +0000 (10:23 -0300)
commit6e761cbc9127fb8fc609aea2265ee8279b8d6c55
tree5c341396728ce7f3c627670b875c2a8c06218f44
parent1e2778e91616086177a255f3fc8c72ecaa564ae6
perf util: Improve error checking for time percent input

The command line like 'perf report --stdio --time 1abc%/1' could be
accepted by perf. It looks not very good.

This patch uses strtod() to replace original atof() and check the entire
string. Now for the same command line, it would return error message
"Invalid time string".

root@skl:/tmp# perf report --stdio --time 1abc%/1
Invalid time string

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Reviewed-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1515596433-24653-4-git-send-email-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/time-utils.c