Defined a new macro #define __packed __attribute__((packed)) used for packing the structures, to make the code look cleaner. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@xxxxxxxxx> --- lib/trace-cmd/include/trace-cmd-local.h | 2 ++ lib/trace-cmd/trace-msg.c | 14 +++++++------- lib/trace-cmd/trace-timesync.c | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/trace-cmd/include/trace-cmd-local.h b/lib/trace-cmd/include/trace-cmd-local.h index 0cd27441..d265e4c8 100644 --- a/lib/trace-cmd/include/trace-cmd-local.h +++ b/lib/trace-cmd/include/trace-cmd-local.h @@ -12,6 +12,8 @@ /* Can be overridden */ void warning(const char *fmt, ...); +#define __packed __attribute__((packed)) + /* trace.dat file format version */ #define FILE_VERSION 6 diff --git a/lib/trace-cmd/trace-msg.c b/lib/trace-cmd/trace-msg.c index e0cdf677..8d2ed38d 100644 --- a/lib/trace-cmd/trace-msg.c +++ b/lib/trace-cmd/trace-msg.c @@ -57,11 +57,11 @@ struct tracecmd_msg_tinit { be32 cpus; be32 page_size; be32 opt_num; -} __attribute__((packed)); +} __packed; struct tracecmd_msg_rinit { be32 cpus; -} __attribute__((packed)); +} __packed; #define TRACE_REQ_PARAM_SIZE (2 * sizeof(int)) enum trace_req_params { @@ -79,7 +79,7 @@ struct tracecmd_msg_trace_req { be32 flags; be32 argc; u64 trace_id; -} __attribute__((packed)); +} __packed; struct tracecmd_msg_trace_resp { be32 flags; @@ -88,18 +88,18 @@ struct tracecmd_msg_trace_resp { u64 trace_id; char tsync_proto_name[TRACECMD_TSYNC_PNAME_LENGTH]; be32 tsync_port; -} __attribute__((packed)); +} __packed; struct tracecmd_msg_tsync { char sync_protocol_name[TRACECMD_TSYNC_PNAME_LENGTH]; be32 sync_msg_id; -} __attribute__((packed)); +} __packed; struct tracecmd_msg_header { be32 size; be32 cmd; be32 cmd_size; -} __attribute__((packed)); +} __packed; #define MSG_MAP \ C(CLOSE, 0, 0), \ @@ -148,7 +148,7 @@ struct tracecmd_msg { struct tracecmd_msg_tsync tsync; }; char *buf; -} __attribute__((packed)); +} __packed; static inline int msg_buf_len(struct tracecmd_msg *msg) { diff --git a/lib/trace-cmd/trace-timesync.c b/lib/trace-cmd/trace-timesync.c index 994a935a..8371a141 100644 --- a/lib/trace-cmd/trace-timesync.c +++ b/lib/trace-cmd/trace-timesync.c @@ -41,7 +41,7 @@ struct tsync_proto { struct tsync_probe_request_msg { be16 cpu; -} __attribute__((packed)); +} __packed; static struct tsync_proto *tsync_proto_list; -- 2.29.2