aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/util.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2018-01-29 08:03:59 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-02-15 07:57:19 -0500
commit6677d26c8befa462eab9be6c5335a939011e7e65 (patch)
tree0a73af32a57be9e549ca2ffd55dd71225f441dd5 /tools/perf/util/util.c
parent8cc42de736b617827a4e7664fb8d7a325bc125bc (diff)
perf tools: Substitute yet another strtoull()
Instead of home grown function let's use what library provides us. Signed-off-by: Andriy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Link: http://lkml.kernel.org/r/20180129130359.1490-1-andriy.shevchenko@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/util.c')
-rw-r--r--tools/perf/util/util.c24
1 files changed, 2 insertions, 22 deletions
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 443892dabedb..1019bbc5dbd8 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -340,35 +340,15 @@ size_t hex_width(u64 v)
340 return n; 340 return n;
341} 341}
342 342
343static int hex(char ch)
344{
345 if ((ch >= '0') && (ch <= '9'))
346 return ch - '0';
347 if ((ch >= 'a') && (ch <= 'f'))
348 return ch - 'a' + 10;
349 if ((ch >= 'A') && (ch <= 'F'))
350 return ch - 'A' + 10;
351 return -1;
352}
353
354/* 343/*
355 * While we find nice hex chars, build a long_val. 344 * While we find nice hex chars, build a long_val.
356 * Return number of chars processed. 345 * Return number of chars processed.
357 */ 346 */
358int hex2u64(const char *ptr, u64 *long_val) 347int hex2u64(const char *ptr, u64 *long_val)
359{ 348{
360 const char *p = ptr; 349 char *p;
361 *long_val = 0;
362
363 while (*p) {
364 const int hex_val = hex(*p);
365 350
366 if (hex_val < 0) 351 *long_val = strtoull(ptr, &p, 16);
367 break;
368
369 *long_val = (*long_val << 4) | hex_val;
370 p++;
371 }
372 352
373 return p - ptr; 353 return p - ptr;
374} 354}