From 5c20a688fd2408ff8dcc66fd8ebc935e228dd803 Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Sun, 2 Jun 2019 21:14:18 +0300 Subject: (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 --- xlators/protocol/client/src/client-handshake.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'xlators/protocol/client') diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c index 01505587243..1fdc96a6ac6 100644 --- a/xlators/protocol/client/src/client-handshake.c +++ b/xlators/protocol/client/src/client-handshake.c @@ -1287,18 +1287,10 @@ client_setvolume(xlator_t *this, struct rpc_clnt *rpc) "Failed to set client opversion in handshake message"); } - ret = dict_serialized_length(options); - if (ret < 0) { - gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_ERROR, - "failed to get serialized length of dict"); + ret = dict_allocate_and_serialize(options, (char **)&req.dict.dict_val, + &req.dict.dict_len); + if (ret != 0) { ret = -1; - goto fail; - } - req.dict.dict_len = ret; - req.dict.dict_val = GF_CALLOC(1, req.dict.dict_len, - gf_client_mt_clnt_req_buf_t); - ret = dict_serialize(options, req.dict.dict_val); - if (ret < 0) { gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_SERIALIZE_FAIL, "failed to serialize " "dictionary"); -- cgit