diff options
author | srijan-sivakumar <ssivakum@redhat.com> | 2020-09-21 19:14:01 +0530 |
---|---|---|
committer | Sanju Rakonde <sanjurakonde@review.gluster.org> | 2020-09-24 03:32:54 +0000 |
commit | ecb8d666753cc536105538b178a9eaf8874dafdf (patch) | |
tree | 3a52d5235b8d3a31b5e86e3f7786231158f7576d /xlators | |
parent | 5a1644c892adeb370fdd6eb2adf0d49e0cf553b4 (diff) |
glusterd: Removing strlen and using existing len field of data_t
Issue: The strlen being used to find the length of the dictionary is
an extra step as there already exists len field in data_t which contains
the same value.
Code Change :
1. Replacing the strlen with len.
2. Removing a typecast which wasn't required.
Fixes: #1497
Change-Id: I2780c3876b17b8825038d222fb489a87e090411f
Signed-off-by: srijan-sivakumar <ssivakum@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index af6a6be5d5c..de932826c90 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -702,9 +702,11 @@ _storeopts(dict_t *dict_value, char *key, data_t *value, void *data) /* * The option_len considers the length of the key value - * pair and along with that '=' and '\n'. + * pair and along with that '=' and '\n', but as value->len + * already considers a NULL at the end of the data, adding + * just 1. */ - option_len = strlen(key) + strlen((char *)value->data) + 2; + option_len = strlen(key) + value->len + 1; if ((VOLINFO_BUFFER_SIZE - dict_data->buffer_len - 1) < option_len) { ret = gf_store_save_items(shandle->fd, dict_data->buffer); @@ -716,7 +718,7 @@ _storeopts(dict_t *dict_value, char *key, data_t *value, void *data) dict_data->buffer[0] = '\0'; } ret = snprintf(dict_data->buffer + dict_data->buffer_len, option_len + 1, - "%s=%s\n", key, (char *)value->data); + "%s=%s\n", key, value->data); if (ret < 0 || ret > option_len + 1) { gf_smsg(this->name, GF_LOG_ERROR, EINVAL, GD_MSG_COPY_FAIL, NULL); return -1; |