[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tip-8c1cedb4466809f9d741a4088314783cb88680a9@git.kernel.org>
Date: Tue, 20 Jun 2017 01:56:05 -0700
From: tip-bot for Taeung Song <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, acme@...hat.com, hpa@...or.com,
mingo@...nel.org, jolsa@...nel.org, treeze.taeung@...il.com,
tglx@...utronix.de, namhyung@...nel.org
Subject: [tip:perf/core] perf config: Invert an if statement to reduce
nesting in cmd_config()
Commit-ID: 8c1cedb4466809f9d741a4088314783cb88680a9
Gitweb: http://git.kernel.org/tip/8c1cedb4466809f9d741a4088314783cb88680a9
Author: Taeung Song <treeze.taeung@...il.com>
AuthorDate: Mon, 8 May 2017 20:07:30 +0900
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Mon, 19 Jun 2017 15:14:58 -0300
perf config: Invert an if statement to reduce nesting in cmd_config()
Signed-off-by: Taeung Song <treeze.taeung@...il.com>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Namhyung Kim <namhyung@...nel.org>
Link: http://lkml.kernel.org/r/1494241650-32210-1-git-send-email-treeze.taeung@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/builtin-config.c | 44 +++++++++++++++++++++++---------------------
1 file changed, 23 insertions(+), 21 deletions(-)
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index 80668fa..7545966 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -204,31 +204,33 @@ int cmd_config(int argc, const char **argv)
}
break;
default:
- if (argc) {
- for (i = 0; argv[i]; i++) {
- char *var, *value;
- char *arg = strdup(argv[i]);
-
- if (!arg) {
- pr_err("%s: strdup failed\n", __func__);
- ret = -1;
- break;
- }
+ if (!argc) {
+ usage_with_options(config_usage, config_options);
+ break;
+ }
- if (parse_config_arg(arg, &var, &value) < 0) {
- free(arg);
- ret = -1;
- break;
- }
+ for (i = 0; argv[i]; i++) {
+ char *var, *value;
+ char *arg = strdup(argv[i]);
- if (value == NULL)
- ret = show_spec_config(set, var);
- else
- ret = set_config(set, config_filename, var, value);
+ if (!arg) {
+ pr_err("%s: strdup failed\n", __func__);
+ ret = -1;
+ break;
+ }
+
+ if (parse_config_arg(arg, &var, &value) < 0) {
free(arg);
+ ret = -1;
+ break;
}
- } else
- usage_with_options(config_usage, config_options);
+
+ if (value == NULL)
+ ret = show_spec_config(set, var);
+ else
+ ret = set_config(set, config_filename, var, value);
+ free(arg);
+ }
}
perf_config_set__delete(set);
Powered by blists - more mailing lists