From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752057AbcGPUpb (ORCPT ); Sat, 16 Jul 2016 16:45:31 -0400 Received: from terminus.zytor.com ([198.137.202.10]:38538 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751733AbcGPUp3 (ORCPT ); Sat, 16 Jul 2016 16:45:29 -0400 Date: Sat, 16 Jul 2016 13:45:13 -0700 From: tip-bot for Jiri Olsa Message-ID: Cc: jolsa@kernel.org, namhyung@kernel.org, gongss@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, acme@redhat.com, tglx@linutronix.de, a.p.zijlstra@chello.nl, hpa@zytor.com, mingo@kernel.org, dsahern@gmail.com Reply-To: dsahern@gmail.com, mingo@kernel.org, tglx@linutronix.de, a.p.zijlstra@chello.nl, hpa@zytor.com, acme@redhat.com, linux-kernel@vger.kernel.org, namhyung@kernel.org, gongss@linux.vnet.ibm.com, jolsa@kernel.org In-Reply-To: <1468567797-27564-4-git-send-email-jolsa@kernel.org> References: <1468567797-27564-4-git-send-email-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] tools lib api fs: Use base 0 in filename__read_ull Git-Commit-ID: db49120a32b347fb93aea3319305932657dd118c X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: db49120a32b347fb93aea3319305932657dd118c Gitweb: http://git.kernel.org/tip/db49120a32b347fb93aea3319305932657dd118c Author: Jiri Olsa AuthorDate: Fri, 15 Jul 2016 09:29:57 +0200 Committer: Arnaldo Carvalho de Melo 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 Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Songshan Gong Link: http://lkml.kernel.org/r/1468567797-27564-4-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- 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; }