summaryrefslogtreecommitdiff
path: root/tools/perf/builtin-config.c
diff options
context:
space:
mode:
authorTaeung Song <treeze.taeung@gmail.com>2017-05-08 14:07:30 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-06-19 21:14:58 +0300
commit8c1cedb4466809f9d741a4088314783cb88680a9 (patch)
tree652f98352de857d5887609d51c2203e280f44dd0 /tools/perf/builtin-config.c
parentec27ae1892f7f8119ce82535ffcc2889ea3bb3d8 (diff)
downloadlinux-8c1cedb4466809f9d741a4088314783cb88680a9.tar.xz
perf config: Invert an if statement to reduce nesting in cmd_config()
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/1494241650-32210-1-git-send-email-treeze.taeung@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-config.c')
-rw-r--r--tools/perf/builtin-config.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index 80668fa7556e..75459668edb2 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);