diff mbox series

[1/5] trace-cmd: Create TRACECMD_MAGIC macro for magic number of trace-cmd data file

Message ID 20200122171329.057095088@goodmis.org (mailing list archive)
State Superseded
Headers show
Series trace-cmd: A few updates | expand

Commit Message

Steven Rostedt Jan. 22, 2020, 5:12 p.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

Instead of copying the magic number around different files, just declare a
macro for it in the exported trace-cmd header and use that.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 include/trace-cmd/trace-cmd.h | 2 ++
 lib/trace-cmd/trace-input.c   | 2 +-
 tracecmd/trace-dump.c         | 3 +--
 3 files changed, 4 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/include/trace-cmd/trace-cmd.h b/include/trace-cmd/trace-cmd.h
index ee8cdc75a9b2..1f5a98b3f7af 100644
--- a/include/trace-cmd/trace-cmd.h
+++ b/include/trace-cmd/trace-cmd.h
@@ -8,6 +8,8 @@ 
 
 #include "traceevent/event-parse.h"
 
+#define TRACECMD_MAGIC { 23, 8, 68 }
+
 #define ARRAY_SIZE(_a) (sizeof(_a) / sizeof((_a)[0]))
 #define __weak __attribute__((weak))
 #define __noreturn __attribute__((noreturn))
diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 68da3a776d19..6d7f0feff3c0 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -2861,7 +2861,7 @@  struct hook_list *tracecmd_hooks(struct tracecmd_input *handle)
 struct tracecmd_input *tracecmd_alloc_fd(int fd)
 {
 	struct tracecmd_input *handle;
-	char test[] = { 23, 8, 68 };
+	char test[] = TRACECMD_MAGIC;
 	unsigned int page_size;
 	char *version;
 	char buf[BUFSIZ];
diff --git a/tracecmd/trace-dump.c b/tracecmd/trace-dump.c
index d95b34c12776..ed6705886e39 100644
--- a/tracecmd/trace-dump.c
+++ b/tracecmd/trace-dump.c
@@ -14,7 +14,6 @@ 
 #include "trace-local.h"
 
 #define DEF_INPUT_FILE	"trace.dat"
-#define MAGIC_HEAD	{ 0x17, 0x08, 0x44 }
 #define TRACING_STR	"tracing"
 #define HEAD_PAGE_STR	"header_page"
 #define HEAD_PAGE_EVENT	"header_event"
@@ -142,7 +141,7 @@  static int read_file_number(int fd, void *digit, int size)
 
 static void dump_initial_format(int fd)
 {
-	char magic[] = MAGIC_HEAD;
+	char magic[] = TRACECMD_MAGIC;
 	char buf[DUMP_SIZE];
 	int val4;