summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/server/src/server-handshake.c
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2019-06-02 21:14:18 +0300
committerAmar Tumballi <amarts@redhat.com>2019-07-22 11:41:13 +0000
commit5c20a688fd2408ff8dcc66fd8ebc935e228dd803 (patch)
tree6205e6c84aea40d964b76323629422c68511365f /xlators/protocol/server/src/server-handshake.c
parent06e92a2ee437c1a81c815129b1d188af0b4fa84e (diff)
(multiple files) use dict_allocate_and_serialize() where applicable.
This function does length, allocation and serialization for you. Change-Id: I142a259952a2fe83dd719442afaefe4a43a8e55e updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
Diffstat (limited to 'xlators/protocol/server/src/server-handshake.c')
-rw-r--r--xlators/protocol/server/src/server-handshake.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c
index a0ff163..17371f4 100644
--- a/xlators/protocol/server/src/server-handshake.c
+++ b/xlators/protocol/server/src/server-handshake.c
@@ -663,22 +663,16 @@ fail:
GF_ASSERT(rsp);
rsp->op_ret = 0;
- ret = dict_serialized_length(reply);
- if (ret > 0) {
- rsp->dict.dict_len = ret;
- rsp->dict.dict_val = GF_CALLOC(1, rsp->dict.dict_len,
- gf_server_mt_rsp_buf_t);
- if (rsp->dict.dict_val) {
- ret = dict_serialize(reply, rsp->dict.dict_val);
- if (ret < 0) {
- gf_msg_debug("server-handshake", 0,
- "failed "
- "to serialize reply dict");
- op_ret = -1;
- op_errno = -ret;
- }
- }
+
+ ret = dict_allocate_and_serialize(reply, (char **)&rsp->dict.dict_val,
+ &rsp->dict.dict_len);
+ if (ret != 0) {
+ ret = -1;
+ gf_msg_debug("server-handshake", 0, "failed to serialize reply dict");
+ op_ret = -1;
+ op_errno = -ret;
}
+
rsp->op_ret = op_ret;
rsp->op_errno = gf_errno_to_error(op_errno);