aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/util/time-utils.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/perf/util/time-utils.c b/tools/perf/util/time-utils.c
index 3f7f18f06982..88510ab6450e 100644
--- a/tools/perf/util/time-utils.c
+++ b/tools/perf/util/time-utils.c
@@ -116,7 +116,8 @@ int perf_time__parse_str(struct perf_time_interval *ptime, const char *ostr)
116 116
117static int parse_percent(double *pcnt, char *str) 117static int parse_percent(double *pcnt, char *str)
118{ 118{
119 char *c; 119 char *c, *endptr;
120 double d;
120 121
121 c = strchr(str, '%'); 122 c = strchr(str, '%');
122 if (c) 123 if (c)
@@ -124,8 +125,11 @@ static int parse_percent(double *pcnt, char *str)
124 else 125 else
125 return -1; 126 return -1;
126 127
127 *pcnt = atof(str) / 100.0; 128 d = strtod(str, &endptr);
129 if (endptr != str + strlen(str))
130 return -1;
128 131
132 *pcnt = d / 100.0;
129 return 0; 133 return 0;
130} 134}
131 135