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>
This commit is contained in:
Taeung Song 2017-05-08 20:07:30 +09:00 committed by Arnaldo Carvalho de Melo
parent ec27ae1892
commit 8c1cedb446
1 changed files with 26 additions and 24 deletions

View File

@ -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 (parse_config_arg(arg, &var, &value) < 0) {
free(arg);
ret = -1;
break;
}
if (value == NULL)
ret = show_spec_config(set, var);
else
ret = set_config(set, config_filename, var, value);
free(arg);
}
} else
if (!argc) {
usage_with_options(config_usage, config_options);
break;
}
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 (parse_config_arg(arg, &var, &value) < 0) {
free(arg);
ret = -1;
break;
}
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);