mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-22 17:01:14 +00:00
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>
This commit is contained in:
parent
0d203166de
commit
db49120a32
1 changed files with 6 additions and 1 deletions
|
@ -283,6 +283,11 @@ int filename__read_int(const char *filename, int *value)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parses @value out of @filename with strtoull.
|
||||||
|
* By using 0 for base, the strtoull detects the
|
||||||
|
* base automatically (see man strtoull).
|
||||||
|
*/
|
||||||
int filename__read_ull(const char *filename, unsigned long long *value)
|
int filename__read_ull(const char *filename, unsigned long long *value)
|
||||||
{
|
{
|
||||||
char line[64];
|
char line[64];
|
||||||
|
@ -292,7 +297,7 @@ int filename__read_ull(const char *filename, unsigned long long *value)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (read(fd, line, sizeof(line)) > 0) {
|
if (read(fd, line, sizeof(line)) > 0) {
|
||||||
*value = strtoull(line, NULL, 10);
|
*value = strtoull(line, NULL, 0);
|
||||||
if (*value != ULLONG_MAX)
|
if (*value != ULLONG_MAX)
|
||||||
err = 0;
|
err = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue