From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Taeung Song <treeze.taeung@gmail.com>,
Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 10/10] perf config: Refactor a duplicated code for obtaining config file name
Date: Wed, 3 May 2017 10:58:26 -0300 [thread overview]
Message-ID: <20170503135826.28675-11-acme@kernel.org> (raw)
In-Reply-To: <20170503135826.28675-1-acme@kernel.org>
From: Taeung Song <treeze.taeung@gmail.com>
We were doing the same sequence to figure out what is the config
pathname to use, fix it by doing it before those two uses.
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1493209268-5543-2-git-send-email-treeze.taeung@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-config.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index 55f04f85b049..80668fa7556e 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -159,6 +159,7 @@ int cmd_config(int argc, const char **argv)
int i, ret = 0;
struct perf_config_set *set;
char *user_config = mkpath("%s/.perfconfig", getenv("HOME"));
+ const char *config_filename;
argc = parse_options(argc, argv, config_options, config_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
@@ -175,6 +176,11 @@ int cmd_config(int argc, const char **argv)
else if (use_user_config)
config_exclusive_filename = user_config;
+ if (!config_exclusive_filename)
+ config_filename = user_config;
+ else
+ config_filename = config_exclusive_filename;
+
/*
* At only 'config' sub-command, individually use the config set
* because of reinitializing with options config file location.
@@ -192,13 +198,9 @@ int cmd_config(int argc, const char **argv)
parse_options_usage(config_usage, config_options, "l", 1);
} else {
ret = show_config(set);
- if (ret < 0) {
- const char * config_filename = config_exclusive_filename;
- if (!config_exclusive_filename)
- config_filename = user_config;
+ if (ret < 0)
pr_err("Nothing configured, "
"please check your %s \n", config_filename);
- }
}
break;
default:
@@ -221,13 +223,8 @@ int cmd_config(int argc, const char **argv)
if (value == NULL)
ret = show_spec_config(set, var);
- else {
- const char *config_filename = config_exclusive_filename;
-
- if (!config_exclusive_filename)
- config_filename = user_config;
+ else
ret = set_config(set, config_filename, var, value);
- }
free(arg);
}
} else
--
2.9.3
next prev parent reply other threads:[~2017-05-03 13:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-03 13:58 [GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo
2017-05-03 13:58 ` [PATCH 01/10] perf buildid: Move prototypes from util.h to build-id.h Arnaldo Carvalho de Melo
2017-05-03 13:58 ` [PATCH 02/10] perf tools: Move event prototypes from util.h to event.h Arnaldo Carvalho de Melo
2017-05-03 13:58 ` [PATCH 03/10] perf memswap: Split the byteswap memory range wrappers from util.[ch] Arnaldo Carvalho de Melo
2017-05-03 13:58 ` [PATCH 04/10] perf tools: Move HAS_BOOL define to where perl headers are used Arnaldo Carvalho de Melo
2017-05-03 13:58 ` [PATCH 05/10] perf ui gtk: Move gtk .so name to the only place where it is used Arnaldo Carvalho de Melo
2017-05-03 13:58 ` [PATCH 06/10] perf units: Move parse_tag_value() to units.[ch] Arnaldo Carvalho de Melo
2017-05-03 13:58 ` [PATCH 07/10] tools lib string: Adopt prefixcmp() from perf and subcmd Arnaldo Carvalho de Melo
2017-05-03 13:58 ` [PATCH 08/10] perf symbols: Accept symbols starting at address 0 Arnaldo Carvalho de Melo
2017-05-03 13:58 ` [PATCH 09/10] perf symbols: Allow user probes on versioned symbols Arnaldo Carvalho de Melo
2017-05-03 13:58 ` Arnaldo Carvalho de Melo [this message]
2017-05-03 17:30 ` [GIT PULL 00/10] perf/core improvements and fixes Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170503135826.28675-11-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=treeze.taeung@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.