linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Taeung Song <treeze.taeung@gmail.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Taeung Song <treeze.taeung@gmail.com>
Subject: [PATCH 1/7] perf config: Refactor a duplicated code for config file name
Date: Wed, 26 Apr 2017 21:21:02 +0900	[thread overview]
Message-ID: <1493209268-5543-2-git-send-email-treeze.taeung@gmail.com> (raw)
In-Reply-To: <1493209268-5543-1-git-send-email-treeze.taeung@gmail.com>

Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Taeung Song <treeze.taeung@gmail.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 55f04f8..80668fa 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.7.4

  reply	other threads:[~2017-04-26 12:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-26 12:21 [PATCH 0/7] perf config: Bugfixes & Refactoring Taeung Song
2017-04-26 12:21 ` Taeung Song [this message]
2017-05-03 17:38   ` [tip:perf/urgent] perf config: Refactor a duplicated code for obtaining config file name tip-bot for Taeung Song
2017-04-26 12:21 ` [PATCH 2/7] perf config: Check list empty before showing configs Taeung Song
2017-05-02 15:12   ` Arnaldo Carvalho de Melo
2017-05-03  4:05     ` Taeung Song
2017-04-26 12:21 ` [PATCH 3/7] perf config: Use none_err for all cases that nothing configured Taeung Song
2017-04-26 12:21 ` [PATCH 4/7] perf config: Invert if statements to reduce nesting in cmd_config() Taeung Song
2017-04-26 12:21 ` [PATCH 5/7] perf config: Correctly check whether it is from system config Taeung Song
2017-04-26 12:21 ` [PATCH 6/7] perf config: Finally write changed configs on config file at a time Taeung Song
2017-04-26 12:21 ` [PATCH 7/7] perf config: No free config set when it's initialization failed Taeung Song
2017-04-26 14:17 [PATCH 1/7] perf config: Refactor a duplicated code for config file name Taeung Song

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=1493209268-5543-2-git-send-email-treeze.taeung@gmail.com \
    --to=treeze.taeung@gmail.com \
    --cc=acme@kernel.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).