Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1444006 > unrolled thread

[PATCH 3/3] tools lib api fs: Use base 0 in filename__read_ull

Started byJiri Olsa <jolsa@kernel.org>
First post2016-07-15 09:40 +0200
Last post2016-07-16 22:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 3/3] tools lib api fs: Use base 0 in filename__read_ull Jiri Olsa <jolsa@kernel.org> - 2016-07-15 09:40 +0200
    [tip:perf/core] tools lib api fs: Use base 0 in filename__read_ull tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-07-16 22:50 +0200

#1444006 — [PATCH 3/3] tools lib api fs: Use base 0 in filename__read_ull

FromJiri Olsa <jolsa@kernel.org>
Date2016-07-15 09:40 +0200
Subject[PATCH 3/3] tools lib api fs: Use base 0 in filename__read_ull
Message-ID<rV5T4-43Z-29@gated-at.bofh.it>
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 cpuinfo_max_freq
sysfs. It should not get affected by this change.

Cc: Songshan Gong <gongss@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/n/tip-f56zxnejrzt9gfernqb034z8@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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.4.11

[toc] | [next] | [standalone]


#1444929 — [tip:perf/core] tools lib api fs: Use base 0 in filename__read_ull

Fromtip-bot for Jiri Olsa <tipbot@zytor.com>
Date2016-07-16 22:50 +0200
Subject[tip:perf/core] tools lib api fs: Use base 0 in filename__read_ull
Message-ID<rVEH8-8rP-35@gated-at.bofh.it>
In reply to#1444006
Commit-ID:  db49120a32b347fb93aea3319305932657dd118c
Gitweb:     http://git.kernel.org/tip/db49120a32b347fb93aea3319305932657dd118c
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Fri, 15 Jul 2016 09:29:57 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 15 Jul 2016 13:38:05 -0300

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>
---
 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 08556cf..ba7094b 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;
 	}

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web