Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1631429

[PATCH 3/7] perf config: Use none_err for all cases that nothing configured

From Taeung Song <treeze.taeung@gmail.com>
Newsgroups linux.kernel
Subject [PATCH 3/7] perf config: Use none_err for all cases that nothing configured
Date 2017-04-26 14:30 +0200
Message-ID <tAueZ-2dU-15@gated-at.bofh.it> (permalink)
References <tAueZ-2dU-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Currently there's only one error message for nothing configured.
Before:

  $ perf config -l
  Nothing configured, please check your /home/taeung/.perfconfig

  $ perf config report.queue-size

So use none_err to handle all cases when nothing configured,
and also use it instead of out_err that skip the error message.

After:

  $ perf config -l
  Nothing configured, please check your /home/taeung/.perfconfig

  $ perf config report.queue-size
  Nothing configured, please check your /home/taeung/.perfconfig

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 | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index 9ec8664..ad0a112 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -188,7 +188,7 @@ int cmd_config(int argc, const char **argv)
 	set = perf_config_set__new();
 	if (!set) {
 		ret = -1;
-		goto out_err;
+		goto none_err;
 	}
 
 	switch (actions) {
@@ -199,8 +199,7 @@ int cmd_config(int argc, const char **argv)
 		} else {
 			ret = show_config(set);
 			if (ret < 0)
-				pr_err("Nothing configured, "
-				       "please check your %s \n", config_filename);
+				goto none_err;
 		}
 		break;
 	default:
@@ -221,9 +220,11 @@ int cmd_config(int argc, const char **argv)
 					break;
 				}
 
-				if (value == NULL)
+				if (value == NULL) {
 					ret = show_spec_config(set, var);
-				else
+					if (ret < 0)
+						goto none_err;
+				} else
 					ret = set_config(set, config_filename, var, value);
 				free(arg);
 			}
@@ -231,7 +232,11 @@ int cmd_config(int argc, const char **argv)
 			usage_with_options(config_usage, config_options);
 	}
 
+none_err:
+	if (ret < 0 && (!set || list_empty(&set->sections)))
+		pr_err("Nothing configured, "
+		       "please check your %s \n", config_filename);
+
 	perf_config_set__delete(set);
-out_err:
 	return ret;
 }
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/7] perf config: Bugfixes & Refactoring Taeung Song <treeze.taeung@gmail.com> - 2017-04-26 14:30 +0200
  [PATCH 3/7] perf config: Use none_err for all cases that nothing configured Taeung Song <treeze.taeung@gmail.com> - 2017-04-26 14:30 +0200
  [PATCH 4/7] perf config: Invert if statements to reduce nesting in cmd_config() Taeung Song <treeze.taeung@gmail.com> - 2017-04-26 14:30 +0200
  [PATCH 2/7] perf config: Check list empty before showing configs Taeung Song <treeze.taeung@gmail.com> - 2017-04-26 14:30 +0200
    Re: [PATCH 2/7] perf config: Check list empty before showing configs Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-05-02 17:20 +0200
      Re: [PATCH 2/7] perf config: Check list empty before showing configs Taeung Song <treeze.taeung@gmail.com> - 2017-05-03 06:10 +0200
  [PATCH 6/7] perf config: Finally write changed configs on config file at a time Taeung Song <treeze.taeung@gmail.com> - 2017-04-26 14:30 +0200
  [PATCH 5/7] perf config: Correctly check whether it is from system config Taeung Song <treeze.taeung@gmail.com> - 2017-04-26 14:30 +0200
  [PATCH 1/7] perf config: Refactor a duplicated code for config file name Taeung Song <treeze.taeung@gmail.com> - 2017-04-26 14:30 +0200
    [tip:perf/urgent] perf config: Refactor a duplicated code for  obtaining config file name tip-bot for Taeung Song <tipbot@zytor.com> - 2017-05-03 19:50 +0200

csiph-web