Skip to content

Commit

Permalink
perf config: Invert an if statement to reduce nesting in cmd_config()
Browse files Browse the repository at this point in the history
Signed-off-by: Taeung Song <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
Taeung authored and acmel committed Jun 19, 2017
1 parent ec27ae1 commit 8c1cedb
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions tools/perf/builtin-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8c1cedb

Please sign in to comment.