All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/7] perf config: Refactor a duplicated code for config file name
@ 2017-04-26 14:17 Taeung Song
  0 siblings, 0 replies; 2+ messages in thread
From: Taeung Song @ 2017-04-26 14:17 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: linux-kernel, Jiri Olsa, Namhyung Kim

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread
* [PATCH 0/7] perf config: Bugfixes & Refactoring
@ 2017-04-26 12:21 Taeung Song
  2017-04-26 12:21 ` [PATCH 1/7] perf config: Refactor a duplicated code for config file name Taeung Song
  0 siblings, 1 reply; 2+ messages in thread
From: Taeung Song @ 2017-04-26 12:21 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-kernel, Jiri Olsa, Namhyung Kim, Taeung Song

Hi all, :)

This is simple patchset for perf-config
to fix small bugs and refactor code.

I'd appreciate some feedback on this patchset.

The code is also avaiable at 'config/refactoring' branch on

  git://github.com/taeung/linux-perf.git


Thanks,
Taeung

Taeung Song (7):
  perf config: Refactor a duplicated code for config file name
  perf config: Check list empty before showing configs
  perf config: Use none_err for all cases that nothing configured
  perf config: Invert if statements to reduce nesting in cmd_config()
  perf config: Correctly check whether it is from system config
  perf config: Finally write changed configs on config file at a time
  perf config: No free config set when it's initialization failed

 tools/perf/builtin-config.c | 92 +++++++++++++++++++++++++--------------------
 tools/perf/util/config.c    |  7 +---
 2 files changed, 54 insertions(+), 45 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-26 14:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-26 14:17 [PATCH 1/7] perf config: Refactor a duplicated code for config file name Taeung Song
  -- strict thread matches above, loose matches on Subject: below --
2017-04-26 12:21 [PATCH 0/7] perf config: Bugfixes & Refactoring Taeung Song
2017-04-26 12:21 ` [PATCH 1/7] perf config: Refactor a duplicated code for config file name Taeung Song

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.