diff options
author | Jiri Olsa <jolsa@kernel.org> | 2016-07-15 03:29:57 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-07-15 12:38:05 -0400 |
commit | db49120a32b347fb93aea3319305932657dd118c (patch) | |
tree | 70520e40723f4534f85df5ef994ce8aa5c1fcace /tools/lib/api | |
parent | 0d203166de37ad50ea826f97570b3a2beea87c9d (diff) |
tools lib api fs: Use base 0 in filename__read_ull
By using 0 for base, the strtoull() detects the base automatically (see
'man strtoull').
ATM we have just one user of this function, the cpu__get_max_freq
function reading the "cpuinfo_max_freq" sysfs file. It should not get
affected by this change.
Committer note:
This change seems motivated by this discussion:
"[PATCH] [RFC V1]s390/perf: fix 'start' address of module's map"
http://lkml.kernel.org/r/20160711120155.GA29929@krava
I.e. this patches paves the way for filename__read_ull() to be used in a
S/390 related fix.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Songshan Gong <gongss@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/1468567797-27564-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib/api')
-rw-r--r-- | tools/lib/api/fs/fs.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c index 08556cf2c70d..ba7094b945ff 100644 --- a/tools/lib/api/fs/fs.c +++ b/tools/lib/api/fs/fs.c | |||
@@ -283,6 +283,11 @@ int filename__read_int(const char *filename, int *value) | |||
283 | return err; | 283 | return err; |
284 | } | 284 | } |
285 | 285 | ||
286 | /* | ||
287 | * Parses @value out of @filename with strtoull. | ||
288 | * By using 0 for base, the strtoull detects the | ||
289 | * base automatically (see man strtoull). | ||
290 | */ | ||
286 | int filename__read_ull(const char *filename, unsigned long long *value) | 291 | int filename__read_ull(const char *filename, unsigned long long *value) |
287 | { | 292 | { |
288 | char line[64]; | 293 | char line[64]; |
@@ -292,7 +297,7 @@ int filename__read_ull(const char *filename, unsigned long long *value) | |||
292 | return -1; | 297 | return -1; |
293 | 298 | ||
294 | if (read(fd, line, sizeof(line)) > 0) { | 299 | if (read(fd, line, sizeof(line)) > 0) { |
295 | *value = strtoull(line, NULL, 10); | 300 | *value = strtoull(line, NULL, 0); |
296 | if (*value != ULLONG_MAX) | 301 | if (*value != ULLONG_MAX) |
297 | err = 0; | 302 | err = 0; |
298 | } | 303 | } |