Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756162AbcCaGzT (ORCPT ); Thu, 31 Mar 2016 02:55:19 -0400 Received: from terminus.zytor.com ([198.137.202.10]:34868 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751522AbcCaGzQ (ORCPT ); Thu, 31 Mar 2016 02:55:16 -0400 Date: Wed, 30 Mar 2016 23:53:38 -0700 From: tip-bot for Taeung Song Message-ID: Cc: peterz@infradead.org, namhyung@kernel.org, acme@redhat.com, tglx@linutronix.de, treeze.taeung@gmail.com, mingo@kernel.org, wangnan0@huawei.com, jolsa@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org Reply-To: acme@redhat.com, namhyung@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org, jolsa@kernel.org, hpa@zytor.com, wangnan0@huawei.com, mingo@kernel.org, treeze.taeung@gmail.com, tglx@linutronix.de In-Reply-To: <1459099340-16911-2-git-send-email-treeze.taeung@gmail.com> References: <1459099340-16911-2-git-send-email-treeze.taeung@gmail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf config: Rework buildid_dir_command_config to perf_buildid_config Git-Commit-ID: 9cb5987c822714352e3eb46806fc260b3cb4ff0d 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 Content-Length: 3105 Lines: 107 Commit-ID: 9cb5987c822714352e3eb46806fc260b3cb4ff0d Gitweb: http://git.kernel.org/tip/9cb5987c822714352e3eb46806fc260b3cb4ff0d Author: Taeung Song AuthorDate: Mon, 28 Mar 2016 02:22:19 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 30 Mar 2016 11:14:09 -0300 perf config: Rework buildid_dir_command_config to perf_buildid_config To avoid repeated calling perf_config() remove buildid_dir_command_config() and add new perf_buildid_config into perf_default_config. Because perf_config() is already called with perf_default_config at main(). Signed-off-by: Taeung Song Acked-by: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Wang Nan Link: http://lkml.kernel.org/r/1459099340-16911-2-git-send-email-treeze.taeung@gmail.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/config.c | 50 +++++++++++++++++------------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index 4e72763..2dd78f4 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c @@ -377,6 +377,21 @@ const char *perf_config_dirname(const char *name, const char *value) return value; } +static int perf_buildid_config(const char *var, const char *value) +{ + /* same dir for all commands */ + if (!strcmp(var, "buildid.dir")) { + const char *dirname = perf_config_dirname(var, value); + + if (!dirname) + return -1; + strncpy(buildid_dir, dirname, MAXPATHLEN-1); + buildid_dir[MAXPATHLEN-1] = '\0'; + } + + return 0; +} + static int perf_default_core_config(const char *var __maybe_unused, const char *value __maybe_unused) { @@ -412,6 +427,9 @@ int perf_default_config(const char *var, const char *value, if (!prefixcmp(var, "llvm.")) return perf_llvm_config(var, value); + if (!prefixcmp(var, "buildid.")) + return perf_buildid_config(var, value); + /* Add other config variables here. */ return 0; } @@ -515,43 +533,11 @@ int config_error_nonbool(const char *var) return error("Missing value for '%s'", var); } -struct buildid_dir_config { - char *dir; -}; - -static int buildid_dir_command_config(const char *var, const char *value, - void *data) -{ - struct buildid_dir_config *c = data; - const char *v; - - /* same dir for all commands */ - if (!strcmp(var, "buildid.dir")) { - v = perf_config_dirname(var, value); - if (!v) - return -1; - strncpy(c->dir, v, MAXPATHLEN-1); - c->dir[MAXPATHLEN-1] = '\0'; - } - return 0; -} - -static void check_buildid_dir_config(void) -{ - struct buildid_dir_config c; - c.dir = buildid_dir; - perf_config(buildid_dir_command_config, &c); -} - void set_buildid_dir(const char *dir) { if (dir) scnprintf(buildid_dir, MAXPATHLEN-1, "%s", dir); - /* try config file */ - if (buildid_dir[0] == '\0') - check_buildid_dir_config(); - /* default to $HOME/.debug */ if (buildid_dir[0] == '\0') { char *v = getenv("HOME");