From 4d8f87806db144552baea60d9b59e9becffe5925 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 30 Sep 2011 22:24:17 -0600 Subject: [PATCH 1/1] Pass more arguments to fio_init_net_cmd() Signed-off-by: Jens Axboe --- client.c | 7 +------ server.c | 6 +----- server.h | 12 ++++++++++-- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/client.c b/client.c index d9e3857e..f9154648 100644 --- a/client.c +++ b/client.c @@ -62,12 +62,7 @@ static int send_file_buf(char *buf, off_t size) cmd = malloc(sizeof(*cmd) + size); - fio_init_net_cmd(cmd); - cmd->opcode = cpu_to_le16(FIO_NET_CMD_JOB_END); - cmd->pdu_len = cpu_to_le32(size); - - memcpy(&cmd->payload, buf, size); - + fio_init_net_cmd(cmd, FIO_NET_CMD_JOB_END, buf, size); fio_net_cmd_crc(cmd); ret = fio_send_data(fio_client_fd, cmd, sizeof(*cmd) + size); diff --git a/server.c b/server.c index a70dc14f..8bbac70f 100644 --- a/server.c +++ b/server.c @@ -373,11 +373,7 @@ int fio_server_text_output(const char *buf, unsigned int len) int size = sizeof(*cmd) + len; cmd = malloc(size); - fio_init_net_cmd(cmd); - cmd->opcode = cpu_to_le16(FIO_NET_CMD_TEXT); - cmd->pdu_len = cpu_to_le32(len); - memcpy(&cmd->payload, buf, len); - + fio_init_net_cmd(cmd, FIO_NET_CMD_TEXT, buf, len); fio_net_cmd_crc(cmd); fio_send_data(server_fd, cmd, size); diff --git a/server.h b/server.h index 969659dd..79449a63 100644 --- a/server.h +++ b/server.h @@ -68,10 +68,18 @@ extern int fio_net_port; #error "Endianness not detected" #endif -static inline void fio_init_net_cmd(struct fio_net_cmd *cmd) +static inline void fio_init_net_cmd(struct fio_net_cmd *cmd, uint16_t opcode, + const void *pdu, uint32_t pdu_len) { memset(cmd, 0, sizeof(*cmd)); - cmd->version = cpu_to_le16(FIO_SERVER_VER1); + + cmd->version = cpu_to_le16(FIO_SERVER_VER1); + cmd->opcode = cpu_to_le16(FIO_NET_CMD_TEXT); + + if (pdu) { + cmd->pdu_len = cpu_to_le32(pdu_len); + memcpy(&cmd->payload, pdu, pdu_len); + } } #endif -- 2.25.1