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  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]
Date:   Thu, 23 Nov 2017 18:33:26 +0200
From:   "Vladislav Valtchev (VMware)" <vladislav.valtchev@...il.com>
To:     rostedt@...dmis.org
Cc:     linux-kernel@...r.kernel.org, y.karadz@...il.com,
        "Vladislav Valtchev (VMware)" <vladislav.valtchev@...il.com>
Subject: [PATCH 02/11] trace-cmd: Extract trace_restart() from trace_record()

In this patch, an entire trace_restart() function has been extracted from
trace_record() and added to the commands table in trace-cmd.c, without any
ad-hoc changes. Now trace_record() is a little bit smaller and all the code
handling the 'restart' command is in a dedicated function.

Signed-off-by: Vladislav Valtchev (VMware) <vladislav.valtchev@...il.com>
---
 trace-cmd.c    |  2 +-
 trace-local.h  |  2 ++
 trace-record.c | 74 ++++++++++++++++++++++++++++++++--------------------------
 3 files changed, 44 insertions(+), 34 deletions(-)

diff --git a/trace-cmd.c b/trace-cmd.c
index de5283c..2b9146e 100644
--- a/trace-cmd.c
+++ b/trace-cmd.c
@@ -107,7 +107,7 @@ struct command commands[] = {
 	{"stop", trace_stop},
 	{"stream", trace_record},
 	{"profile", trace_record},
-	{"restart", trace_record},
+	{"restart", trace_restart},
 	{"reset", trace_record},
 	{"stat", trace_stat},
 	{"options", trace_option},
diff --git a/trace-local.h b/trace-local.h
index 8010680..2b55aa8 100644
--- a/trace-local.h
+++ b/trace-local.h
@@ -60,6 +60,8 @@ void trace_record(int argc, char **argv);
 
 void trace_stop(int argc, char **argv);
 
+void trace_restart(int argc, char **argv);
+
 void trace_report(int argc, char **argv);
 
 void trace_split(int argc, char **argv);
diff --git a/trace-record.c b/trace-record.c
index c7f7df7..e9cce12 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -4239,6 +4239,47 @@ void trace_stop(int argc, char **argv)
 	exit(0);
 }
 
+void trace_restart(int argc, char **argv)
+{
+	int topt = 0;
+	struct buffer_instance *instance = &top_instance;
+
+	init_instance(instance);
+
+	for (;;) {
+		int c;
+
+		c = getopt(argc-1, argv+1, "hatB:");
+		if (c == -1)
+			break;
+		switch (c) {
+		case 'h':
+			usage(argv);
+			break;
+		case 'B':
+			instance = create_instance(optarg);
+			if (!instance)
+				die("Failed to create instance");
+			add_instance(instance);
+			break;
+		case 'a':
+			add_all_instances();
+			break;
+		case 't':
+			/* Force to use top instance */
+			topt = 1;
+			instance = &top_instance;
+			break;
+		default:
+			usage(argv);
+		}
+
+	}
+	update_first_instance(instance, topt);
+	tracecmd_enable_tracing();
+	exit(0);
+}
+
 void trace_record(int argc, char **argv)
 {
 	const char *plugin = NULL;
@@ -4289,39 +4330,6 @@ void trace_record(int argc, char **argv)
 	else if ((profile = strcmp(argv[1], "profile") == 0)) {
 		handle_init = trace_init_profile;
 		events = 1;
-	} else if (strcmp(argv[1], "restart") == 0) {
-		for (;;) {
-			int c;
-
-			c = getopt(argc-1, argv+1, "hatB:");
-			if (c == -1)
-				break;
-			switch (c) {
-			case 'h':
-				usage(argv);
-				break;
-			case 'B':
-				instance = create_instance(optarg);
-				if (!instance)
-					die("Failed to create instance");
-				add_instance(instance);
-				break;
-			case 'a':
-				add_all_instances();
-				break;
-			case 't':
-				/* Force to use top instance */
-				topt = 1;
-				instance = &top_instance;
-				break;
-			default:
-				usage(argv);
-			}
-
-		}
-		update_first_instance(instance, topt);
-		tracecmd_enable_tracing();
-		exit(0);
 	} else if (strcmp(argv[1], "reset") == 0) {
 		/* if last arg is -a, then -b and -d apply to all instances */
 		int last_specified_all = 0;
-- 
2.14.1

Powered by blists - more mailing lists