提交 b6229487 编写于 作者: H Hyunchul Lee 提交者: Namjae Jeon

ksmbd: remove macros in transport_ipc.c

Remove macros in transport_ipc.c
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NHyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: NNamjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: NSteve French <stfrench@microsoft.com>
上级 6c5e36d1
...@@ -38,8 +38,6 @@ static DEFINE_IDA(ipc_ida); ...@@ -38,8 +38,6 @@ static DEFINE_IDA(ipc_ida);
static unsigned int ksmbd_tools_pid; static unsigned int ksmbd_tools_pid;
#define KSMBD_IPC_MSG_HANDLE(m) (*(unsigned int *)m)
static bool ksmbd_ipc_validate_version(struct genl_info *m) static bool ksmbd_ipc_validate_version(struct genl_info *m)
{ {
if (m->genlhdr->version != KSMBD_GENL_VERSION) { if (m->genlhdr->version != KSMBD_GENL_VERSION) {
...@@ -56,12 +54,9 @@ static bool ksmbd_ipc_validate_version(struct genl_info *m) ...@@ -56,12 +54,9 @@ static bool ksmbd_ipc_validate_version(struct genl_info *m)
struct ksmbd_ipc_msg { struct ksmbd_ipc_msg {
unsigned int type; unsigned int type;
unsigned int sz; unsigned int sz;
unsigned char ____payload[0]; unsigned char payload[];
}; };
#define KSMBD_IPC_MSG_PAYLOAD(m) \
((void *)(((struct ksmbd_ipc_msg *)(m))->____payload))
struct ipc_msg_table_entry { struct ipc_msg_table_entry {
unsigned int handle; unsigned int handle;
unsigned int type; unsigned int type;
...@@ -251,7 +246,7 @@ static void ipc_msg_handle_free(int handle) ...@@ -251,7 +246,7 @@ static void ipc_msg_handle_free(int handle)
static int handle_response(int type, void *payload, size_t sz) static int handle_response(int type, void *payload, size_t sz)
{ {
int handle = KSMBD_IPC_MSG_HANDLE(payload); unsigned int handle = *(unsigned int *)payload;
struct ipc_msg_table_entry *entry; struct ipc_msg_table_entry *entry;
int ret = 0; int ret = 0;
...@@ -432,7 +427,7 @@ static int ipc_msg_send(struct ksmbd_ipc_msg *msg) ...@@ -432,7 +427,7 @@ static int ipc_msg_send(struct ksmbd_ipc_msg *msg)
if (!nlh) if (!nlh)
goto out; goto out;
ret = nla_put(skb, msg->type, msg->sz, KSMBD_IPC_MSG_PAYLOAD(msg)); ret = nla_put(skb, msg->type, msg->sz, msg->payload);
if (ret) { if (ret) {
genlmsg_cancel(skb, nlh); genlmsg_cancel(skb, nlh);
goto out; goto out;
...@@ -509,7 +504,7 @@ struct ksmbd_login_response *ksmbd_ipc_login_request(const char *account) ...@@ -509,7 +504,7 @@ struct ksmbd_login_response *ksmbd_ipc_login_request(const char *account)
return NULL; return NULL;
msg->type = KSMBD_EVENT_LOGIN_REQUEST; msg->type = KSMBD_EVENT_LOGIN_REQUEST;
req = KSMBD_IPC_MSG_PAYLOAD(msg); req = (struct ksmbd_login_request *)msg->payload;
req->handle = ksmbd_acquire_id(&ipc_ida); req->handle = ksmbd_acquire_id(&ipc_ida);
strscpy(req->account, account, KSMBD_REQ_MAX_ACCOUNT_NAME_SZ); strscpy(req->account, account, KSMBD_REQ_MAX_ACCOUNT_NAME_SZ);
...@@ -532,7 +527,7 @@ ksmbd_ipc_spnego_authen_request(const char *spnego_blob, int blob_len) ...@@ -532,7 +527,7 @@ ksmbd_ipc_spnego_authen_request(const char *spnego_blob, int blob_len)
return NULL; return NULL;
msg->type = KSMBD_EVENT_SPNEGO_AUTHEN_REQUEST; msg->type = KSMBD_EVENT_SPNEGO_AUTHEN_REQUEST;
req = KSMBD_IPC_MSG_PAYLOAD(msg); req = (struct ksmbd_spnego_authen_request *)msg->payload;
req->handle = ksmbd_acquire_id(&ipc_ida); req->handle = ksmbd_acquire_id(&ipc_ida);
req->spnego_blob_len = blob_len; req->spnego_blob_len = blob_len;
memcpy(req->spnego_blob, spnego_blob, blob_len); memcpy(req->spnego_blob, spnego_blob, blob_len);
...@@ -564,7 +559,7 @@ ksmbd_ipc_tree_connect_request(struct ksmbd_session *sess, ...@@ -564,7 +559,7 @@ ksmbd_ipc_tree_connect_request(struct ksmbd_session *sess,
return NULL; return NULL;
msg->type = KSMBD_EVENT_TREE_CONNECT_REQUEST; msg->type = KSMBD_EVENT_TREE_CONNECT_REQUEST;
req = KSMBD_IPC_MSG_PAYLOAD(msg); req = (struct ksmbd_tree_connect_request *)msg->payload;
req->handle = ksmbd_acquire_id(&ipc_ida); req->handle = ksmbd_acquire_id(&ipc_ida);
req->account_flags = sess->user->flags; req->account_flags = sess->user->flags;
...@@ -597,7 +592,7 @@ int ksmbd_ipc_tree_disconnect_request(unsigned long long session_id, ...@@ -597,7 +592,7 @@ int ksmbd_ipc_tree_disconnect_request(unsigned long long session_id,
return -ENOMEM; return -ENOMEM;
msg->type = KSMBD_EVENT_TREE_DISCONNECT_REQUEST; msg->type = KSMBD_EVENT_TREE_DISCONNECT_REQUEST;
req = KSMBD_IPC_MSG_PAYLOAD(msg); req = (struct ksmbd_tree_disconnect_request *)msg->payload;
req->session_id = session_id; req->session_id = session_id;
req->connect_id = connect_id; req->connect_id = connect_id;
...@@ -620,7 +615,7 @@ int ksmbd_ipc_logout_request(const char *account) ...@@ -620,7 +615,7 @@ int ksmbd_ipc_logout_request(const char *account)
return -ENOMEM; return -ENOMEM;
msg->type = KSMBD_EVENT_LOGOUT_REQUEST; msg->type = KSMBD_EVENT_LOGOUT_REQUEST;
req = KSMBD_IPC_MSG_PAYLOAD(msg); req = (struct ksmbd_logout_request *)msg->payload;
strscpy(req->account, account, KSMBD_REQ_MAX_ACCOUNT_NAME_SZ); strscpy(req->account, account, KSMBD_REQ_MAX_ACCOUNT_NAME_SZ);
ret = ipc_msg_send(msg); ret = ipc_msg_send(msg);
...@@ -643,7 +638,7 @@ ksmbd_ipc_share_config_request(const char *name) ...@@ -643,7 +638,7 @@ ksmbd_ipc_share_config_request(const char *name)
return NULL; return NULL;
msg->type = KSMBD_EVENT_SHARE_CONFIG_REQUEST; msg->type = KSMBD_EVENT_SHARE_CONFIG_REQUEST;
req = KSMBD_IPC_MSG_PAYLOAD(msg); req = (struct ksmbd_share_config_request *)msg->payload;
req->handle = ksmbd_acquire_id(&ipc_ida); req->handle = ksmbd_acquire_id(&ipc_ida);
strscpy(req->share_name, name, KSMBD_REQ_MAX_SHARE_NAME); strscpy(req->share_name, name, KSMBD_REQ_MAX_SHARE_NAME);
...@@ -664,7 +659,7 @@ struct ksmbd_rpc_command *ksmbd_rpc_open(struct ksmbd_session *sess, int handle) ...@@ -664,7 +659,7 @@ struct ksmbd_rpc_command *ksmbd_rpc_open(struct ksmbd_session *sess, int handle)
return NULL; return NULL;
msg->type = KSMBD_EVENT_RPC_REQUEST; msg->type = KSMBD_EVENT_RPC_REQUEST;
req = KSMBD_IPC_MSG_PAYLOAD(msg); req = (struct ksmbd_rpc_command *)msg->payload;
req->handle = handle; req->handle = handle;
req->flags = ksmbd_session_rpc_method(sess, handle); req->flags = ksmbd_session_rpc_method(sess, handle);
req->flags |= KSMBD_RPC_OPEN_METHOD; req->flags |= KSMBD_RPC_OPEN_METHOD;
...@@ -686,7 +681,7 @@ struct ksmbd_rpc_command *ksmbd_rpc_close(struct ksmbd_session *sess, int handle ...@@ -686,7 +681,7 @@ struct ksmbd_rpc_command *ksmbd_rpc_close(struct ksmbd_session *sess, int handle
return NULL; return NULL;
msg->type = KSMBD_EVENT_RPC_REQUEST; msg->type = KSMBD_EVENT_RPC_REQUEST;
req = KSMBD_IPC_MSG_PAYLOAD(msg); req = (struct ksmbd_rpc_command *)msg->payload;
req->handle = handle; req->handle = handle;
req->flags = ksmbd_session_rpc_method(sess, handle); req->flags = ksmbd_session_rpc_method(sess, handle);
req->flags |= KSMBD_RPC_CLOSE_METHOD; req->flags |= KSMBD_RPC_CLOSE_METHOD;
...@@ -709,7 +704,7 @@ struct ksmbd_rpc_command *ksmbd_rpc_write(struct ksmbd_session *sess, int handle ...@@ -709,7 +704,7 @@ struct ksmbd_rpc_command *ksmbd_rpc_write(struct ksmbd_session *sess, int handle
return NULL; return NULL;
msg->type = KSMBD_EVENT_RPC_REQUEST; msg->type = KSMBD_EVENT_RPC_REQUEST;
req = KSMBD_IPC_MSG_PAYLOAD(msg); req = (struct ksmbd_rpc_command *)msg->payload;
req->handle = handle; req->handle = handle;
req->flags = ksmbd_session_rpc_method(sess, handle); req->flags = ksmbd_session_rpc_method(sess, handle);
req->flags |= rpc_context_flags(sess); req->flags |= rpc_context_flags(sess);
...@@ -733,7 +728,7 @@ struct ksmbd_rpc_command *ksmbd_rpc_read(struct ksmbd_session *sess, int handle) ...@@ -733,7 +728,7 @@ struct ksmbd_rpc_command *ksmbd_rpc_read(struct ksmbd_session *sess, int handle)
return NULL; return NULL;
msg->type = KSMBD_EVENT_RPC_REQUEST; msg->type = KSMBD_EVENT_RPC_REQUEST;
req = KSMBD_IPC_MSG_PAYLOAD(msg); req = (struct ksmbd_rpc_command *)msg->payload;
req->handle = handle; req->handle = handle;
req->flags = ksmbd_session_rpc_method(sess, handle); req->flags = ksmbd_session_rpc_method(sess, handle);
req->flags |= rpc_context_flags(sess); req->flags |= rpc_context_flags(sess);
...@@ -757,7 +752,7 @@ struct ksmbd_rpc_command *ksmbd_rpc_ioctl(struct ksmbd_session *sess, int handle ...@@ -757,7 +752,7 @@ struct ksmbd_rpc_command *ksmbd_rpc_ioctl(struct ksmbd_session *sess, int handle
return NULL; return NULL;
msg->type = KSMBD_EVENT_RPC_REQUEST; msg->type = KSMBD_EVENT_RPC_REQUEST;
req = KSMBD_IPC_MSG_PAYLOAD(msg); req = (struct ksmbd_rpc_command *)req->payload;
req->handle = handle; req->handle = handle;
req->flags = ksmbd_session_rpc_method(sess, handle); req->flags = ksmbd_session_rpc_method(sess, handle);
req->flags |= rpc_context_flags(sess); req->flags |= rpc_context_flags(sess);
...@@ -782,7 +777,7 @@ struct ksmbd_rpc_command *ksmbd_rpc_rap(struct ksmbd_session *sess, void *payloa ...@@ -782,7 +777,7 @@ struct ksmbd_rpc_command *ksmbd_rpc_rap(struct ksmbd_session *sess, void *payloa
return NULL; return NULL;
msg->type = KSMBD_EVENT_RPC_REQUEST; msg->type = KSMBD_EVENT_RPC_REQUEST;
req = KSMBD_IPC_MSG_PAYLOAD(msg); req = (struct ksmbd_rpc_command *)req->payload;
req->handle = ksmbd_acquire_id(&ipc_ida); req->handle = ksmbd_acquire_id(&ipc_ida);
req->flags = rpc_context_flags(sess); req->flags = rpc_context_flags(sess);
req->flags |= KSMBD_RPC_RAP_METHOD; req->flags |= KSMBD_RPC_RAP_METHOD;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册