diff mbox series

[15/38] trace-cmd: Add tracecmd_msg_init() helper function

Message ID 20180103175336.982581934@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>

We will eventually be getting rid of tracecmd_msg_create() multiplexer and
having separate functions for creating different msg types. This will
require having a generic tracecmd_msg_init() to initialize the msg to a
default state.

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

Patch

diff --git a/trace-msg.c b/trace-msg.c
index 406f44105470..5c55eae8f4b3 100644
--- a/trace-msg.c
+++ b/trace-msg.c
@@ -219,6 +219,13 @@  static int make_rinit(struct tracecmd_msg *msg)
 	return 0;
 }
 
+static void tracecmd_msg_init(u32 cmd, struct tracecmd_msg *msg)
+{
+	memset(msg, 0, sizeof(*msg));
+	msg->hdr.cmd = htonl(cmd);
+	msg->hdr.size = htonl(MSG_HDR_LEN);
+}
+
 static int tracecmd_msg_create(u32 cmd, struct tracecmd_msg *msg)
 {
 	int ret = 0;
@@ -228,8 +235,7 @@  static int tracecmd_msg_create(u32 cmd, struct tracecmd_msg *msg)
 		return -EINVAL;
 	}
 
-	memset(msg, 0, sizeof(*msg));
-	msg->hdr.cmd = htonl(cmd);
+	tracecmd_msg_init(cmd, msg);
 
 	switch (cmd) {
 	case MSG_TINIT:
@@ -242,8 +248,6 @@  static int tracecmd_msg_create(u32 cmd, struct tracecmd_msg *msg)
 		break;
 	}
 
-	msg->hdr.size = htonl(MSG_HDR_LEN);
-
 	return ret;
 }