lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1493209268-5543-5-git-send-email-treeze.taeung@gmail.com>
Date:   Wed, 26 Apr 2017 21:21:05 +0900
From:   Taeung Song <treeze.taeung@...il.com>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:     linux-kernel@...r.kernel.org, Jiri Olsa <jolsa@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>,
        Taeung Song <treeze.taeung@...il.com>
Subject: [PATCH 4/7] perf config: Invert if statements to reduce nesting in cmd_config()

Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Namhyung Kim <namhyung@...nel.org>
Signed-off-by: Taeung Song <treeze.taeung@...il.com>
---
 tools/perf/builtin-config.c | 50 ++++++++++++++++++++++++---------------------
 1 file changed, 27 insertions(+), 23 deletions(-)

diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index ad0a112..f4596ef 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -203,33 +203,37 @@ 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 (!arg) {
+				pr_err("%s: strdup failed\n", __func__);
+				ret = -1;
+				break;
+			}
 
-				if (value == NULL) {
-					ret = show_spec_config(set, var);
-					if (ret < 0)
-						goto none_err;
-				} else
-					ret = set_config(set, config_filename, var, value);
+			if (parse_config_arg(arg, &var, &value) < 0) {
 				free(arg);
+				ret = -1;
+				break;
 			}
-		} else
-			usage_with_options(config_usage, config_options);
+
+			if (value) {
+				ret = set_config(set, config_filename, var, value);
+				continue;
+			}
+			ret = show_spec_config(set, var);
+			if (ret < 0)
+				goto none_err;
+
+			free(arg);
+		}
 	}
 
 none_err:
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ