diff mbox series

[06/38] trace-cmd: Move tracecmd_msg_send_and_wait_for_msg() into its only user

Message ID 20180103175335.611564144@goodmis.org (mailing list archive)
State Superseded, archived
Headers show
Series trace-cmd: Simplify the msg handling | expand

Commit Message

Steven Rostedt Jan. 3, 2018, 5:52 p.m. UTC
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

tracecmd_msg_send_and_wait_for_msg() is a static function that is only used
once. Since multiplexing the send code is complex and really each msg type
should be processed at where it is used instead of a multiplexer, open code
this send function in its only user.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 trace-msg.c | 30 +++++++++---------------------
 1 file changed, 9 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/trace-msg.c b/trace-msg.c
index df45526600c5..4d462f999a4d 100644
--- a/trace-msg.c
+++ b/trace-msg.c
@@ -421,41 +421,29 @@  static int tracecmd_msg_wait_for_msg(int fd, struct tracecmd_msg *msg)
 	return 0;
 }
 
-static int tracecmd_msg_send_and_wait_for_msg(int fd, u32 cmd,
-					      struct tracecmd_msg *recv_msg)
+int tracecmd_msg_send_init_data(int fd)
 {
-	struct tracecmd_msg msg;
+	struct tracecmd_msg send_msg;
+	struct tracecmd_msg recv_msg;
+	int i, cpus;
 	int ret;
 
-	ret = tracecmd_msg_create(cmd, &msg);
-	if (ret < 0)
-		return ret;
-
-	ret = tracecmd_msg_send(fd, &msg);
+	ret = tracecmd_msg_create(MSG_TINIT, &send_msg);
 	if (ret < 0)
 		return ret;
 
-	ret = tracecmd_msg_wait_for_msg(fd, recv_msg);
+	ret = tracecmd_msg_send(fd, &send_msg);
 	if (ret < 0)
 		return ret;
 
-	return 0;
-}
-
-int tracecmd_msg_send_init_data(int fd)
-{
-	struct tracecmd_msg msg;
-	int i, cpus;
-	int ret;
-
-	ret = tracecmd_msg_send_and_wait_for_msg(fd, MSG_TINIT, &msg);
+	ret = tracecmd_msg_wait_for_msg(fd, &recv_msg);
 	if (ret < 0)
 		return ret;
 
-	cpus = ntohl(msg.data.rinit.cpus);
+	cpus = ntohl(recv_msg.data.rinit.cpus);
 	client_ports = malloc_or_die(sizeof(int) * cpus);
 	for (i = 0; i < cpus; i++)
-		client_ports[i] = ntohl(msg.data.rinit.port_array[i]);
+		client_ports[i] = ntohl(recv_msg.data.rinit.port_array[i]);
 
 	/* Next, send meta data */
 	send_metadata = true;