Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1444580
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 06/24] tools lib api fs: Use base 0 in filename__read_ull |
| Date | 2016-07-15 23:00 +0200 |
| Message-ID | <rVing-38N-47@gated-at.bofh.it> (permalink) |
| References | <rVinf-38N-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Jiri Olsa <jolsa@kernel.org>
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>
---
tools/lib/api/fs/fs.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
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)
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)
{
char line[64];
@@ -292,7 +297,7 @@ int filename__read_ull(const char *filename, unsigned long long *value)
return -1;
if (read(fd, line, sizeof(line)) > 0) {
- *value = strtoull(line, NULL, 10);
+ *value = strtoull(line, NULL, 0);
if (*value != ULLONG_MAX)
err = 0;
}
--
2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[GIT PULL 00/24] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-07-15 23:00 +0200 [PATCH 06/24] tools lib api fs: Use base 0 in filename__read_ull Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-07-15 23:00 +0200 [PATCH 17/24] perf evlist: Setup backward mmap state machine Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-07-15 23:00 +0200 [PATCH 20/24] perf tools: Enable overwrite settings Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-07-15 23:00 +0200 [PATCH 16/24] perf evlist: Drop evlist->backward Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-07-15 23:00 +0200 [PATCH 10/24] perf evlist: Update mmap related APIs and helpers Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-07-15 23:00 +0200 [PATCH 13/24] perf evlist: Extract common code in mmap failure processing Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-07-15 23:00 +0200 [PATCH 09/24] tools lib fd array: Allow associating a pointer cookie with each entry Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-07-15 23:00 +0200 [PATCH 02/24] perf tools: Do not provide dup sched_getcpu() prototype on Android Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-07-15 23:00 +0200 [PATCH 08/24] tools: Simplify BITS_PER_LONG define Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-07-15 23:00 +0200 Re: [GIT PULL 00/24] perf/core improvements and fixes Ingo Molnar <mingo@kernel.org> - 2016-07-16 22:40 +0200
csiph-web