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


Groups > linux.kernel > #1637376 > unrolled thread

[PATCH v2 1/4] perf config: Invert a if statement to reduce nesting in cmd_config()

Started byTaeung Song <treeze.taeung@gmail.com>
First post2017-05-08 13:10 +0200
Last post2017-05-08 13:10 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH v2 1/4] perf config: Invert a if statement to reduce nesting in cmd_config() Taeung Song <treeze.taeung@gmail.com> - 2017-05-08 13:10 +0200

#1637376 — [PATCH v2 1/4] perf config: Invert a if statement to reduce nesting in cmd_config()

FromTaeung Song <treeze.taeung@gmail.com>
Date2017-05-08 13:10 +0200
Subject[PATCH v2 1/4] perf config: Invert a if statement to reduce nesting in cmd_config()
Message-ID<tEOIa-39M-13@gated-at.bofh.it>
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 | 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);
-- 
2.7.4

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web