summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/encryption/crypt/src/crypt.c22
-rw-r--r--xlators/encryption/crypt/src/metadata.c2
-rw-r--r--xlators/features/bit-rot/src/bitd/bit-rot-scrub.c5
-rw-r--r--xlators/features/bit-rot/src/bitd/bit-rot.c2
-rw-r--r--xlators/features/cloudsync/src/cloudsync-plugins/src/cloudsyncs3/src/libcloudsyncs3.c2
-rw-r--r--xlators/features/gfid-access/src/gfid-access.c9
-rw-r--r--xlators/features/leases/src/leases-internal.c2
-rw-r--r--xlators/features/locks/src/common.c2
-rw-r--r--xlators/features/marker/src/marker-quota.c2
-rw-r--r--xlators/features/shard/src/shard.c8
-rw-r--r--xlators/features/shard/src/shard.h6
-rw-r--r--xlators/features/trash/src/trash.c7
-rw-r--r--xlators/meta/src/graph-dir.c2
-rw-r--r--xlators/meta/src/subvolumes-dir.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-mgmt.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c9
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-replace-brick.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rpc-ops.c8
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c8
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-syncop.h2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c4
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.c3
-rw-r--r--xlators/mount/fuse/src/fuse-helpers.c3
-rw-r--r--xlators/nfs/server/src/mount3.c44
-rw-r--r--xlators/nfs/server/src/mount3udp_svc.c2
-rw-r--r--xlators/nfs/server/src/nfs-fops.c2
-rw-r--r--xlators/nfs/server/src/nfs3-helpers.c14
-rw-r--r--xlators/performance/io-cache/src/page.c1
-rw-r--r--xlators/performance/md-cache/src/md-cache.c2
-rw-r--r--xlators/performance/quick-read/src/quick-read.c2
-rw-r--r--xlators/protocol/client/src/client-lk.c37
-rw-r--r--xlators/storage/bd/src/bd.c6
-rw-r--r--xlators/storage/posix/src/posix-helpers.c27
-rw-r--r--xlators/storage/posix/src/posix-inode-fd-ops.c17
34 files changed, 141 insertions, 129 deletions
diff --git a/xlators/encryption/crypt/src/crypt.c b/xlators/encryption/crypt/src/crypt.c
index f6e1823..93d64c8 100644
--- a/xlators/encryption/crypt/src/crypt.c
+++ b/xlators/encryption/crypt/src/crypt.c
@@ -43,7 +43,7 @@ static crypt_local_t *crypt_alloc_local(call_frame_t *frame, xlator_t *this,
{
crypt_local_t *local = NULL;
- local = GF_CALLOC (1, sizeof (*local), gf_crypt_mt_local);
+ local = GF_CALLOC (1, sizeof (crypt_local_t), gf_crypt_mt_local);
if (!local) {
gf_log(this->name, GF_LOG_ERROR, "out of memory");
return NULL;
@@ -92,7 +92,7 @@ static struct crypt_inode_info *alloc_inode_info(crypt_local_t *local,
{
struct crypt_inode_info *info;
- info = GF_CALLOC(1, sizeof(*info), gf_crypt_mt_inode);
+ info = GF_CALLOC(1, sizeof(struct crypt_inode_info), gf_crypt_mt_inode);
if (!info) {
local->op_ret = -1;
local->op_errno = ENOMEM;
@@ -100,9 +100,8 @@ static struct crypt_inode_info *alloc_inode_info(crypt_local_t *local,
"Can not allocate inode info");
return NULL;
}
- memset(info, 0, sizeof(*info));
#if DEBUG_CRYPT
- info->loc = GF_CALLOC(1, sizeof(*loc), gf_crypt_mt_loc);
+ info->loc = GF_CALLOC(1, sizeof(loc_t), gf_crypt_mt_loc);
if (!info->loc) {
gf_log("crypt", GF_LOG_WARNING, "Can not allocate loc");
GF_FREE(info);
@@ -2181,12 +2180,11 @@ static int32_t crypt_open(call_frame_t *frame,
local = crypt_alloc_local(frame, this, GF_FOP_OPEN);
if (!local)
goto error;
- local->loc = GF_CALLOC(1, sizeof(*loc), gf_crypt_mt_loc);
+ local->loc = GF_CALLOC(1, sizeof(loc_t), gf_crypt_mt_loc);
if (!local->loc) {
ret = ENOMEM;
goto error;
}
- memset(local->loc, 0, sizeof(*local->loc));
ret = loc_copy(local->loc, loc);
if (ret) {
GF_FREE(local->loc);
@@ -3261,10 +3259,9 @@ static int32_t linkop_grab_local(call_frame_t *frame,
}
local->fd = fd;
local->flags = flags;
- local->loc = GF_CALLOC(1, sizeof(*oldloc), gf_crypt_mt_loc);
+ local->loc = GF_CALLOC(1, sizeof(loc_t), gf_crypt_mt_loc);
if (!local->loc)
goto error;
- memset(local->loc, 0, sizeof(*local->loc));
ret = loc_copy(local->loc, oldloc);
if (ret) {
GF_FREE(local->loc);
@@ -3272,13 +3269,12 @@ static int32_t linkop_grab_local(call_frame_t *frame,
goto error;
}
if (newloc) {
- local->newloc = GF_CALLOC(1, sizeof(*newloc), gf_crypt_mt_loc);
+ local->newloc = GF_CALLOC(1, sizeof(loc_t), gf_crypt_mt_loc);
if (!local->newloc) {
loc_wipe(local->loc);
GF_FREE(local->loc);
goto error;
}
- memset(local->newloc, 0, sizeof(*local->newloc));
ret = loc_copy(local->newloc, newloc);
if (ret) {
loc_wipe(local->loc);
@@ -3971,10 +3967,9 @@ static int32_t crypt_stat(call_frame_t *frame,
local = crypt_alloc_local(frame, this, GF_FOP_STAT);
if (!local)
goto error;
- local->loc = GF_CALLOC(1, sizeof(*loc), gf_crypt_mt_loc);
+ local->loc = GF_CALLOC(1, sizeof(loc_t), gf_crypt_mt_loc);
if (!local->loc)
goto error;
- memset(local->loc, 0, sizeof(*local->loc));
ret = loc_copy(local->loc, loc);
if (ret) {
GF_FREE(local->loc);
@@ -4052,10 +4047,9 @@ static int32_t crypt_lookup(call_frame_t *frame,
local = crypt_alloc_local(frame, this, GF_FOP_LOOKUP);
if (!local)
goto error;
- local->loc = GF_CALLOC(1, sizeof(*loc), gf_crypt_mt_loc);
+ local->loc = GF_CALLOC(1, sizeof(loc_t), gf_crypt_mt_loc);
if (!local->loc)
goto error;
- memset(local->loc, 0, sizeof(*local->loc));
ret = loc_copy(local->loc, loc);
if (ret) {
GF_FREE(local->loc);
diff --git a/xlators/encryption/crypt/src/metadata.c b/xlators/encryption/crypt/src/metadata.c
index cd2bb7d..96fe7d6 100644
--- a/xlators/encryption/crypt/src/metadata.c
+++ b/xlators/encryption/crypt/src/metadata.c
@@ -483,7 +483,7 @@ static int32_t open_format_v1(unsigned char *wire,
/* the case of partial open */
return 0;
- fmt = GF_CALLOC(1, len, gf_crypt_mt_mtd);
+ fmt = GF_MALLOC(len, gf_crypt_mt_mtd);
if (!fmt)
return ENOMEM;
memcpy(fmt, wire, len);
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
index 8e432ae..e2665ac 100644
--- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
+++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
@@ -127,7 +127,7 @@ bitd_scrub_post_compute_check (xlator_t *this,
}
signlen = signptr->signaturelen;
- *signature = GF_CALLOC (1, sizeof (br_isignature_out_t) + signlen,
+ *signature = GF_MALLOC (sizeof (br_isignature_out_t) + signlen,
gf_common_mt_char);
(void) memcpy (*signature, signptr,
@@ -389,8 +389,7 @@ br_scrubber_scrub_begin (xlator_t *this, struct br_fsscan_entry *fsentry)
goto unrefd; /* skip this object */
/* if all's good, proceed to calculate the hash */
- md = GF_CALLOC (SHA256_DIGEST_LENGTH, sizeof (*md),
- gf_common_mt_char);
+ md = GF_MALLOC (SHA256_DIGEST_LENGTH, gf_common_mt_char);
if (!md)
goto unrefd;
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c
index 66e5894..cf59232 100644
--- a/xlators/features/bit-rot/src/bitd/bit-rot.c
+++ b/xlators/features/bit-rot/src/bitd/bit-rot.c
@@ -393,7 +393,7 @@ br_object_read_sign (inode_t *linked_inode, fd_t *fd, br_object_t *object,
this = object->this;
- md = GF_CALLOC (SHA256_DIGEST_LENGTH, sizeof (*md), gf_common_mt_char);
+ md = GF_MALLOC (SHA256_DIGEST_LENGTH, gf_common_mt_char);
if (!md) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM, BRB_MSG_NO_MEMORY,
"failed to allocate memory for saving hash of the "
diff --git a/xlators/features/cloudsync/src/cloudsync-plugins/src/cloudsyncs3/src/libcloudsyncs3.c b/xlators/features/cloudsync/src/cloudsync-plugins/src/cloudsyncs3/src/libcloudsyncs3.c
index dc6a598..e36bf71 100644
--- a/xlators/features/cloudsync/src/cloudsync-plugins/src/cloudsyncs3/src/libcloudsyncs3.c
+++ b/xlators/features/cloudsync/src/cloudsync-plugins/src/cloudsyncs3/src/libcloudsyncs3.c
@@ -298,7 +298,7 @@ aws_b64_encode(const unsigned char *input, int length)
BIO_flush(b64);
BIO_get_mem_ptr(b64, &bptr);
- buff = GF_CALLOC(1, (bptr->length), gf_common_mt_char);
+ buff = GF_MALLOC(bptr->length, gf_common_mt_char);
memcpy(buff, bptr->data, bptr->length - 1);
buff[bptr->length - 1] = 0;
diff --git a/xlators/features/gfid-access/src/gfid-access.c b/xlators/features/gfid-access/src/gfid-access.c
index 0a82321..79c2ee9 100644
--- a/xlators/features/gfid-access/src/gfid-access.c
+++ b/xlators/features/gfid-access/src/gfid-access.c
@@ -140,7 +140,7 @@ ga_newfile_parse_args (xlator_t *this, data_t *data)
goto err;
}
- args->bname = GF_CALLOC (1, (len + 1), gf_common_mt_char);
+ args->bname = GF_MALLOC (len + 1, gf_common_mt_char);
if (args->bname == NULL)
goto err;
@@ -181,7 +181,7 @@ ga_newfile_parse_args (xlator_t *this, data_t *data)
args->gfid);
goto err;
}
- args->args.symlink.linkpath = GF_CALLOC (1, len + 1,
+ args->args.symlink.linkpath = GF_MALLOC (len + 1,
gf_common_mt_char);
if (args->args.symlink.linkpath == NULL)
goto err;
@@ -265,11 +265,12 @@ ga_heal_parse_args (xlator_t *this, data_t *data)
if (len == blob_len)
goto err;
- args->bname = GF_CALLOC (1, len + 1, gf_common_mt_char);
+ args->bname = GF_MALLOC (len + 1, gf_common_mt_char);
if (!args->bname)
goto err;
memcpy (args->bname, blob, len);
+ args->bname[len] = '\0';
blob_len -= (len + 1);
if (blob_len)
@@ -318,7 +319,7 @@ ga_fill_tmp_loc (loc_t *loc, xlator_t *this, uuid_t gfid,
new_loc->name++;
}
- gfid_ptr = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
+ gfid_ptr = GF_MALLOC (sizeof(uuid_t), gf_common_mt_uuid_t);
if (!gfid_ptr) {
ret = -1;
goto out;
diff --git a/xlators/features/leases/src/leases-internal.c b/xlators/features/leases/src/leases-internal.c
index 475576e..fd0996e 100644
--- a/xlators/features/leases/src/leases-internal.c
+++ b/xlators/features/leases/src/leases-internal.c
@@ -900,7 +900,7 @@ __recall_lease (xlator_t *this, lease_inode_ctx_t *lease_ctx)
if (!timer) {
goto out;
}
- timer_data = GF_CALLOC (1, sizeof (*timer_data),
+ timer_data = GF_MALLOC (sizeof (lease_timer_data_t),
gf_leases_mt_timer_data_t);
if (!timer_data) {
GF_FREE (timer);
diff --git a/xlators/features/locks/src/common.c b/xlators/features/locks/src/common.c
index 324187a..b4d8aa3 100644
--- a/xlators/features/locks/src/common.c
+++ b/xlators/features/locks/src/common.c
@@ -521,7 +521,7 @@ __copy_lock(posix_lock_t *src)
{
posix_lock_t *dst;
- dst = GF_CALLOC(1, sizeof(posix_lock_t), gf_locks_mt_posix_lock_t);
+ dst = GF_MALLOC(sizeof(posix_lock_t), gf_locks_mt_posix_lock_t);
if (dst != NULL) {
memcpy (dst, src, sizeof(posix_lock_t));
dst->client_uid = gf_strdup(src->client_uid);
diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c
index 620201d..6d3c5ea 100644
--- a/xlators/features/marker/src/marker-quota.c
+++ b/xlators/features/marker/src/marker-quota.c
@@ -332,7 +332,7 @@ quota_dict_set_size_meta (xlator_t *this, dict_t *dict,
quota_meta_t *value = NULL;
char size_key[QUOTA_KEY_MAX] = {0, };
- value = GF_CALLOC (2, sizeof (quota_meta_t), gf_common_quota_meta_t);
+ value = GF_MALLOC (2 * sizeof (quota_meta_t), gf_common_quota_meta_t);
if (value == NULL) {
goto out;
}
diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c
index 6c075ac..a12e553 100644
--- a/xlators/features/shard/src/shard.c
+++ b/xlators/features/shard/src/shard.c
@@ -1357,7 +1357,7 @@ shard_lookup_internal_dir (call_frame_t *frame, xlator_t *this,
priv = this->private;
local->post_res_handler = post_res_handler;
- gfid = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
+ gfid = GF_MALLOC (sizeof(uuid_t), gf_common_mt_uuid_t);
if (!gfid)
goto err;
@@ -1378,6 +1378,7 @@ shard_lookup_internal_dir (call_frame_t *frame, xlator_t *this,
loc = &local->dot_shard_rm_loc;
break;
default:
+ bzero(*gfid, sizeof(uuid_t));
break;
}
@@ -2266,7 +2267,7 @@ shard_create_gfid_dict (dict_t *dict)
if (!new)
return NULL;
- gfid = GF_CALLOC (1, sizeof (uuid_t), gf_common_mt_char);
+ gfid = GF_MALLOC (sizeof (uuid_t), gf_common_mt_char);
if (!gfid) {
ret = -1;
goto out;
@@ -5615,7 +5616,7 @@ shard_mkdir_internal_dir (call_frame_t *frame, xlator_t *this,
priv = this->private;
local->post_res_handler = handler;
- gfid = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
+ gfid = GF_MALLOC (sizeof(uuid_t), gf_common_mt_uuid_t);
if (!gfid)
goto err;
@@ -5629,6 +5630,7 @@ shard_mkdir_internal_dir (call_frame_t *frame, xlator_t *this,
loc = &local->dot_shard_rm_loc;
break;
default:
+ bzero(*gfid, sizeof(uuid_t));
break;
}
diff --git a/xlators/features/shard/src/shard.h b/xlators/features/shard/src/shard.h
index ac3813c..7a263f4 100644
--- a/xlators/features/shard/src/shard.h
+++ b/xlators/features/shard/src/shard.h
@@ -120,7 +120,7 @@ shard_unlock_entrylk (call_frame_t *frame, xlator_t *this);
int64_t *__size_attr = NULL; \
uint64_t *__bs = 0; \
\
- __bs = GF_CALLOC (1, sizeof (uint64_t), gf_shard_mt_uint64_t); \
+ __bs = GF_MALLOC (sizeof (uint64_t), gf_shard_mt_uint64_t); \
if (!__bs) \
goto label; \
*__bs = hton64 (block_size); \
@@ -142,8 +142,8 @@ shard_unlock_entrylk (call_frame_t *frame, xlator_t *this);
__size_attr, 8 * 4); \
if (__ret) { \
gf_msg (this->name, GF_LOG_WARNING, 0, \
- SHARD_MSG_DICT_OP_FAILED, "Failed to set key: %s " \
- "on path %s", GF_XATTR_SHARD_FILE_SIZE, (loc)->path); \
+ SHARD_MSG_DICT_OP_FAILED, "Failed to set key: %s " \
+ "on path %s", GF_XATTR_SHARD_FILE_SIZE, (loc)->path); \
GF_FREE (__size_attr); \
goto label; \
} \
diff --git a/xlators/features/trash/src/trash.c b/xlators/features/trash/src/trash.c
index a59b186..9e429e3 100644
--- a/xlators/features/trash/src/trash.c
+++ b/xlators/features/trash/src/trash.c
@@ -485,8 +485,7 @@ trash_dir_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (!data) {
goto out;
}
- priv->oldtrash_dir = GF_CALLOC (1, PATH_MAX,
- gf_common_mt_char);
+ priv->oldtrash_dir = GF_MALLOC (PATH_MAX, gf_common_mt_char);
if (!priv->oldtrash_dir) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
ret = ENOMEM;
@@ -541,7 +540,7 @@ trash_internalop_dir_lookup_cbk (call_frame_t *frame, void *cookie,
local = frame->local;
if (op_ret != 0 && op_errno == ENOENT) {
loc_wipe (&local->loc);
- gfid_ptr = GF_CALLOC (1, sizeof(uuid_t),
+ gfid_ptr = GF_MALLOC (sizeof(uuid_t),
gf_common_mt_uuid_t);
if (!gfid_ptr) {
ret = ENOMEM;
@@ -657,7 +656,7 @@ trash_dir_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
"directory %s ",
priv->newtrash_dir);
- gfid_ptr = GF_CALLOC (1, sizeof(uuid_t),
+ gfid_ptr = GF_MALLOC (sizeof(uuid_t),
gf_common_mt_uuid_t);
if (!gfid_ptr) {
ret = ENOMEM;
diff --git a/xlators/meta/src/graph-dir.c b/xlators/meta/src/graph-dir.c
index 541e806..c3a6e8b 100644
--- a/xlators/meta/src/graph-dir.c
+++ b/xlators/meta/src/graph-dir.c
@@ -45,7 +45,7 @@ graph_dir_fill (xlator_t *this, inode_t *inode, struct meta_dirent **dp)
for (xl = graph->first; xl; xl = xl->next)
count++;
- dirents = GF_CALLOC (sizeof (*dirents), count, gf_meta_mt_dirents_t);
+ dirents = GF_MALLOC (sizeof (*dirents) * count, gf_meta_mt_dirents_t);
if (!dirents)
return -1;
diff --git a/xlators/meta/src/subvolumes-dir.c b/xlators/meta/src/subvolumes-dir.c
index 00218b1..59db75e 100644
--- a/xlators/meta/src/subvolumes-dir.c
+++ b/xlators/meta/src/subvolumes-dir.c
@@ -30,7 +30,7 @@ subvolumes_dir_fill (xlator_t *this, inode_t *dir, struct meta_dirent **dp)
for (subv = xl->children; subv; subv = subv->next)
count++;
- dirents = GF_CALLOC (sizeof (*dirents), count, gf_meta_mt_dirents_t);
+ dirents = GF_MALLOC (sizeof (*dirents) * count, gf_meta_mt_dirents_t);
if (!dirents)
return -1;
diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c
index 5b7d782..a924dd3 100644
--- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c
+++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c
@@ -2180,7 +2180,7 @@ glusterd_mgmt_v3_initiate_all_phases (rpcsvc_request_t *req, glusterd_op_t op,
/* Save the MY_UUID as the originator_uuid. This originator_uuid
* will be used by is_origin_glusterd() to determine if a node
* is the originator node for a command. */
- originator_uuid = GF_CALLOC (1, sizeof(uuid_t),
+ originator_uuid = GF_MALLOC (sizeof(uuid_t),
gf_common_mt_uuid_t);
if (!originator_uuid) {
ret = -1;
@@ -2416,7 +2416,7 @@ glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op,
/* Save the MY_UUID as the originator_uuid. This originator_uuid
* will be used by is_origin_glusterd() to determine if a node
* is the originator node for a command. */
- originator_uuid = GF_CALLOC (1, sizeof(uuid_t),
+ originator_uuid = GF_MALLOC (sizeof(uuid_t),
gf_common_mt_uuid_t);
if (!originator_uuid) {
ret = -1;
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index cd2c364..551672c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -189,7 +189,7 @@ glusterd_generate_txn_id (dict_t *dict, uuid_t **txn_id)
GF_ASSERT (priv);
GF_ASSERT (dict);
- *txn_id = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
+ *txn_id = GF_MALLOC (sizeof(uuid_t), gf_common_mt_uuid_t);
if (!*txn_id)
goto out;
@@ -1421,8 +1421,7 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
if (!gf_uuid_compare (brickinfo->uuid, MY_UUID)) {
trash_path_len = strlen (value) +
strlen (brickinfo->path) + 2;
- trash_path = GF_CALLOC (1,
- trash_path_len,
+ trash_path = GF_MALLOC (trash_path_len,
gf_common_mt_char);
snprintf (trash_path, trash_path_len,
"%s/%s", brickinfo->path,
@@ -5889,7 +5888,7 @@ glusterd_op_ac_stage_op (glusterd_op_sm_event_t *event, void *ctx)
status);
}
- txn_id = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
+ txn_id = GF_MALLOC (sizeof(uuid_t), gf_common_mt_uuid_t);
if (txn_id)
gf_uuid_copy (*txn_id, event->txn_id);
@@ -6010,7 +6009,7 @@ glusterd_op_ac_commit_op (glusterd_op_sm_event_t *event, void *ctx)
"'Volume %s' failed: %d", gd_op_list[req_ctx->op],
status);
- txn_id = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
+ txn_id = GF_MALLOC (sizeof(uuid_t), gf_common_mt_uuid_t);
if (txn_id)
gf_uuid_copy (*txn_id, event->txn_id);
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
index de8663f..c3c7d72 100644
--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
+++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
@@ -604,7 +604,7 @@ glusterd_mgmt_v3_initiate_replace_brick_cmd_phases (rpcsvc_request_t *req,
GF_ASSERT (conf);
txn_generation = conf->generation;
- originator_uuid = GF_CALLOC (1, sizeof(uuid_t),
+ originator_uuid = GF_MALLOC (sizeof(uuid_t),
gf_common_mt_uuid_t);
if (!originator_uuid) {
ret = -1;
diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
index fc859c0..be5979c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
@@ -1829,7 +1829,7 @@ glusterd_mgmt_v3_lock_peers (call_frame_t *frame, xlator_t *this,
ret = -1;
goto out;
}
- frame->cookie = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
+ frame->cookie = GF_MALLOC (sizeof(uuid_t), gf_common_mt_uuid_t);
if (!frame->cookie) {
ret = -1;
goto out;
@@ -1910,7 +1910,7 @@ glusterd_mgmt_v3_unlock_peers (call_frame_t *frame, xlator_t *this,
ret = -1;
goto out;
}
- frame->cookie = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
+ frame->cookie = GF_MALLOC (sizeof(uuid_t), gf_common_mt_uuid_t);
if (!frame->cookie) {
ret = -1;
goto out;
@@ -2033,7 +2033,7 @@ glusterd_stage_op (call_frame_t *frame, xlator_t *this,
ret = -1;
goto out;
}
- frame->cookie = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
+ frame->cookie = GF_MALLOC (sizeof(uuid_t), gf_common_mt_uuid_t);
if (!frame->cookie) {
ret = -1;
goto out;
@@ -2114,7 +2114,7 @@ glusterd_commit_op (call_frame_t *frame, xlator_t *this,
ret = -1;
goto out;
}
- frame->cookie = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
+ frame->cookie = GF_MALLOC (sizeof(uuid_t), gf_common_mt_uuid_t);
if (!frame->cookie) {
ret = -1;
goto out;
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index 1f292ae..5d0e15a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -4160,7 +4160,7 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op,
goto out;
}
- uuid_ptr = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
+ uuid_ptr = GF_MALLOC (sizeof(uuid_t), gf_common_mt_uuid_t);
if (!uuid_ptr) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
GD_MSG_NO_MEMORY, "Out Of Memory");
@@ -4213,7 +4213,7 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op,
goto out;
}
- uuid_ptr = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
+ uuid_ptr = GF_MALLOC (sizeof(uuid_t), gf_common_mt_uuid_t);
if (!uuid_ptr) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
GD_MSG_NO_MEMORY, "Out Of Memory");
@@ -4359,7 +4359,7 @@ glusterd_handle_snapshot_clone (rpcsvc_request_t *req, glusterd_op_t op,
goto out;
}
- uuid_ptr = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
+ uuid_ptr = GF_MALLOC (sizeof(uuid_t), gf_common_mt_uuid_t);
if (!uuid_ptr) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
GD_MSG_NO_MEMORY, "Out Of Memory");
@@ -4411,7 +4411,7 @@ glusterd_handle_snapshot_clone (rpcsvc_request_t *req, glusterd_op_t op,
goto out;
}
- uuid_ptr = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
+ uuid_ptr = GF_MALLOC (sizeof(uuid_t), gf_common_mt_uuid_t);
if (!uuid_ptr) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
GD_MSG_NO_MEMORY, "Out Of Memory");
diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.h b/xlators/mgmt/glusterd/src/glusterd-syncop.h
index 6c5fbf9..e5f3aa6 100644
--- a/xlators/mgmt/glusterd/src/glusterd-syncop.h
+++ b/xlators/mgmt/glusterd/src/glusterd-syncop.h
@@ -40,7 +40,7 @@
} while (0)
#define GD_ALLOC_COPY_UUID(dst_ptr, uuid, ret) do { \
- dst_ptr = GF_CALLOC (1, sizeof (*dst_ptr), gf_common_mt_uuid_t); \
+ dst_ptr = GF_MALLOC (sizeof (*dst_ptr), gf_common_mt_uuid_t); \
if (dst_ptr) { \
gf_uuid_copy (*dst_ptr, uuid); \
ret = 0; \
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 51c81db..612fa35 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -9685,7 +9685,7 @@ glusterd_append_status_dicts (dict_t *dst, dict_t *src)
if (ret)
goto out;
- dst_sts_val = GF_CALLOC (1, sizeof(gf_gsync_status_t),
+ dst_sts_val = GF_MALLOC (sizeof(gf_gsync_status_t),
gf_common_mt_gsync_status_t);
if (!dst_sts_val) {
gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM,
@@ -12194,7 +12194,7 @@ glusterd_set_originator_uuid (dict_t *dict)
GF_ASSERT (dict);
- originator_uuid = GF_CALLOC (1, sizeof(uuid_t),
+ originator_uuid = GF_MALLOC (sizeof(uuid_t),
gf_common_mt_uuid_t);
if (!originator_uuid) {
ret = -1;
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
index ee50329..29bb80a 100644
--- a/xlators/mount/fuse/src/fuse-bridge.c
+++ b/xlators/mount/fuse/src/fuse-bridge.c
@@ -3637,13 +3637,14 @@ fuse_getxattr_resume (fuse_state_t *state)
(strcmp (state->name, VIRTUAL_GFID_XATTR_KEY) == 0)) {
/* send glusterfs gfid in binary form */
- value = GF_CALLOC (16 + 1, sizeof(char),
+ value = GF_MALLOC (16 + 1,
gf_common_mt_char);
if (!value) {
send_fuse_err (state->this, state->finh, ENOMEM);
goto internal_out;
}
memcpy (value, state->loc.inode->gfid, 16);
+ value[16] = '\0';
send_fuse_xattr (THIS, state->finh, value, 16, state->size);
GF_FREE (value);
diff --git a/xlators/mount/fuse/src/fuse-helpers.c b/xlators/mount/fuse/src/fuse-helpers.c
index cb3e081..a4e80b3 100644
--- a/xlators/mount/fuse/src/fuse-helpers.c
+++ b/xlators/mount/fuse/src/fuse-helpers.c
@@ -550,7 +550,8 @@ fuse_do_flip_xattr_ns (char *okey, const char *nns, char **nkey)
okey = strchr (okey, '.');
GF_ASSERT (okey);
- key = GF_CALLOC (1, strlen (nns) + strlen(okey) + 1,
+ int key_len = strlen (nns) + strlen(okey);
+ key = GF_MALLOC (key_len + 1,
gf_common_mt_char);
if (!key) {
ret = -1;
diff --git a/xlators/nfs/server/src/mount3.c b/xlators/nfs/server/src/mount3.c
index 187c975..f3d7def 100644
--- a/xlators/nfs/server/src/mount3.c
+++ b/xlators/nfs/server/src/mount3.c
@@ -761,6 +761,7 @@ mnt3svc_lookup_mount_cbk (call_frame_t *frame, void *cookie,
char *path = NULL;
uuid_t mountid = {1, };
char fhstr[1536];
+ int alloclen = 0;
req = (rpcsvc_request_t *)frame->local;
@@ -786,14 +787,16 @@ mnt3svc_lookup_mount_cbk (call_frame_t *frame, void *cookie,
if (status != MNT3_OK)
goto xmit_res;
- path = GF_CALLOC (PATH_MAX, sizeof (char), gf_nfs_mt_char);
+ alloclen = strlen(mntxl->name) + 2;
+ path = GF_MALLOC (alloclen, gf_nfs_mt_char);
if (!path) {
- gf_msg (GF_MNT, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY,
- "Out of memory");
+ gf_msg (GF_MNT, GF_LOG_ERROR, ENOMEM,
+ NFS_MSG_NO_MEMORY,
+ "Memory allocation failed.");
goto xmit_res;
}
- snprintf (path, PATH_MAX, "/%s", mntxl->name);
+ snprintf (path, alloclen, "/%s", mntxl->name);
mnt3svc_update_mountlist (ms, req, path, NULL);
GF_FREE (path);
if (gf_nfs_dvm_off (nfs_state (ms->nfsx))) {
@@ -1148,18 +1151,19 @@ mnt3_resolve_subdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
nfs3_fh_build_child_fh (&mres->parentfh, buf, &fh);
if (strlen (mres->remainingdir) <= 0) {
- size_t alloclen;
+ int alloclen;
op_ret = -1;
mntstat = MNT3_OK;
/* Construct the full path */
+ int resolveloc_path_len = strlen(mres->resolveloc.path);
alloclen = strlen (mres->exp->expname) +
- strlen (mres->resolveloc.path) + 1;
- mres->exp->fullpath = GF_CALLOC (alloclen, sizeof (char),
- gf_nfs_mt_char);
+ resolveloc_path_len + 1;
+ mres->exp->fullpath = GF_MALLOC (alloclen, gf_nfs_mt_char);
if (!mres->exp->fullpath) {
- gf_msg (GF_MNT, GF_LOG_CRITICAL, ENOMEM,
- NFS_MSG_NO_MEMORY, "Allocation failed.");
+ gf_msg (GF_MNT, GF_LOG_ERROR, ENOMEM,
+ NFS_MSG_NO_MEMORY,
+ "Memory allocation failed.");
goto err;
}
snprintf (mres->exp->fullpath, alloclen, "%s%s",
@@ -1178,7 +1182,9 @@ mnt3_resolve_subdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto err;
}
- path = GF_CALLOC (PATH_MAX, sizeof (char), gf_nfs_mt_char);
+ alloclen = strlen (mres->exp->vol->name) +
+ resolveloc_path_len + 2;
+ path = GF_MALLOC (alloclen, gf_nfs_mt_char);
if (!path) {
gf_msg (GF_MNT, GF_LOG_ERROR, ENOMEM,
NFS_MSG_NO_MEMORY,
@@ -1190,7 +1196,7 @@ mnt3_resolve_subdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
*/
__mnt3_build_mountid_from_path (authorized_path, fh.mountid);
- snprintf (path, PATH_MAX, "/%s%s", mres->exp->vol->name,
+ snprintf (path, alloclen, "/%s%s", mres->exp->vol->name,
mres->resolveloc.path);
mnt3svc_update_mountlist (mres->mstate, mres->req,
@@ -1293,12 +1299,12 @@ mnt3_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
/* Building the actual mount path to be mounted */
path_len = strlen (mres->exp->vol->name) + strlen (absolute_path)
+ strlen (mres->remainingdir) + 1;
- real_loc = GF_CALLOC (1, path_len, gf_nfs_mt_char);
+ real_loc = GF_MALLOC (path_len, gf_nfs_mt_char);
if (!real_loc) {
ret = -ENOMEM;
goto mnterr;
}
- sprintf (real_loc , "%s%s", mres->exp->vol->name, absolute_path);
+ snprintf (real_loc, path_len, "%s%s", mres->exp->vol->name, absolute_path);
gf_path_strip_trailing_slashes (real_loc);
/* There may entries after symlink in the mount path,
@@ -2314,7 +2320,7 @@ __build_mountlist (struct mount3_state *ms, int *count)
if (!first)
first = mlist;
- mlist->ml_directory = GF_CALLOC (namelen + 2, sizeof (char),
+ mlist->ml_directory = GF_MALLOC (namelen + 2,
gf_nfs_mt_char);
if (!mlist->ml_directory) {
gf_msg (GF_MNT, GF_LOG_ERROR, ENOMEM,
@@ -2325,7 +2331,7 @@ __build_mountlist (struct mount3_state *ms, int *count)
strcpy (mlist->ml_directory, me->exname);
namelen = strlen (me->hostname);
- mlist->ml_hostname = GF_CALLOC (namelen + 2, sizeof (char),
+ mlist->ml_hostname = GF_MALLOC (namelen + 2,
gf_nfs_mt_char);
if (!mlist->ml_hostname) {
gf_msg (GF_MNT, GF_LOG_ERROR, ENOMEM,
@@ -2654,7 +2660,6 @@ mnt3_xlchildren_to_exports (rpcsvc_t *svc, struct mount3_state *ms)
if (!nfs_subvolume_started (nfs, ent->vol))
continue;
- namelen = strlen (ent->expname) + 1;
elist = GF_CALLOC (1, sizeof (*elist), gf_nfs_mt_exportnode);
if (!elist) {
gf_msg (GF_MNT, GF_LOG_ERROR, ENOMEM,
@@ -2663,7 +2668,8 @@ mnt3_xlchildren_to_exports (rpcsvc_t *svc, struct mount3_state *ms)
}
if (!first)
first = elist;
- elist->ex_dir = GF_CALLOC (namelen + 2, sizeof (char),
+ namelen = strlen (ent->expname);
+ elist->ex_dir = GF_MALLOC (namelen + 2,
gf_nfs_mt_char);
if (!elist->ex_dir) {
gf_msg (GF_MNT, GF_LOG_ERROR, ENOMEM,
@@ -3324,7 +3330,7 @@ mnt3_init_export_ent (struct mount3_state *ms, xlator_t *xl, char *exportpath,
else
alloclen = strlen (xl->name) + 2;
- exp->expname = GF_CALLOC (alloclen, sizeof (char), gf_nfs_mt_char);
+ exp->expname = GF_MALLOC (alloclen, gf_nfs_mt_char);
if (!exp->expname) {
gf_msg (GF_MNT, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY,
"Memory allocation failed");
diff --git a/xlators/nfs/server/src/mount3udp_svc.c b/xlators/nfs/server/src/mount3udp_svc.c
index 8256a59..a9499bf 100644
--- a/xlators/nfs/server/src/mount3udp_svc.c
+++ b/xlators/nfs/server/src/mount3udp_svc.c
@@ -110,7 +110,7 @@ mountudpproc3_umnt_3_svc(dirpath **dp, struct svc_req *req)
char *mpath = (char *) *dp;
xlator_t *nfsx = THIS;
- stat = GF_CALLOC (1, sizeof(mountstat3), gf_nfs_mt_mountstat3);
+ stat = GF_MALLOC (sizeof(mountstat3), gf_nfs_mt_mountstat3);
if (stat == NULL) {
gf_msg (GF_MNT, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY,
"Unable to allocate memory");
diff --git a/xlators/nfs/server/src/nfs-fops.c b/xlators/nfs/server/src/nfs-fops.c
index 7c2aab5..4414100 100644
--- a/xlators/nfs/server/src/nfs-fops.c
+++ b/xlators/nfs/server/src/nfs-fops.c
@@ -334,7 +334,7 @@ nfs_gfid_dict (inode_t *inode)
int ret = -1;
uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
- dyngfid = GF_CALLOC (1, sizeof (uuid_t), gf_common_mt_char);
+ dyngfid = GF_MALLOC (sizeof (uuid_t), gf_common_mt_char);
if (dyngfid == NULL)
return (NULL);
diff --git a/xlators/nfs/server/src/nfs3-helpers.c b/xlators/nfs/server/src/nfs3-helpers.c
index 0b97709..27edf47 100644
--- a/xlators/nfs/server/src/nfs3-helpers.c
+++ b/xlators/nfs/server/src/nfs3-helpers.c
@@ -673,6 +673,7 @@ entry3 *
nfs3_fill_entry3 (gf_dirent_t *entry, struct nfs3_fh *dfh)
{
entry3 *ent = NULL;
+ int name_len = 0;
if ((!entry) || (!dfh))
return NULL;
@@ -692,14 +693,15 @@ nfs3_fill_entry3 (gf_dirent_t *entry, struct nfs3_fh *dfh)
nfs3_funge_root_dotdot_dirent (entry, dfh);
ent->fileid = entry->d_ino;
ent->cookie = entry->d_off;
- ent->name = GF_CALLOC ((strlen (entry->d_name) + 1), sizeof (char),
- gf_nfs_mt_char);
+ name_len = strlen(entry->d_name);
+ ent->name = GF_MALLOC (name_len + 1, gf_nfs_mt_char);
if (!ent->name) {
GF_FREE (ent);
ent = NULL;
goto err;
}
strcpy (ent->name, entry->d_name);
+ ent->name[name_len] = '\0';
err:
return ent;
@@ -732,7 +734,7 @@ nfs3_fh_to_post_op_fh3 (struct nfs3_fh *fh)
pfh.handle_follows = 1;
- fhp = GF_CALLOC (1, sizeof (*fh), gf_nfs_mt_char);
+ fhp = GF_MALLOC (sizeof (*fh), gf_nfs_mt_char);
if (!fhp)
return pfh;
@@ -747,6 +749,7 @@ nfs3_fill_entryp3 (gf_dirent_t *entry, struct nfs3_fh *dirfh, uint64_t devid)
{
entryp3 *ent = NULL;
struct nfs3_fh newfh = {{0}, };
+ int name_len = 0;
if ((!entry) || (!dirfh))
return NULL;
@@ -767,14 +770,15 @@ nfs3_fill_entryp3 (gf_dirent_t *entry, struct nfs3_fh *dirfh, uint64_t devid)
ent->fileid = entry->d_ino;
ent->cookie = entry->d_off;
- ent->name = GF_CALLOC ((strlen (entry->d_name) + 1), sizeof (char),
- gf_nfs_mt_char);
+ name_len = strlen (entry->d_name);
+ ent->name = GF_MALLOC (name_len + 1, gf_nfs_mt_char);
if (!ent->name) {
GF_FREE (ent);
ent = NULL;
goto err;
}
strcpy (ent->name, entry->d_name);
+ ent->name[name_len] = '\0';
nfs3_fh_build_child_fh (dirfh, &entry->d_stat, &newfh);
nfs3_map_deviceid_to_statdev (&entry->d_stat, devid);
diff --git a/xlators/performance/io-cache/src/page.c b/xlators/performance/io-cache/src/page.c
index 50f5e19..33e728c 100644
--- a/xlators/performance/io-cache/src/page.c
+++ b/xlators/performance/io-cache/src/page.c
@@ -853,6 +853,7 @@ ioc_frame_unwind (call_frame_t *frame)
}
list_for_each_entry_safe (fill, next, &local->fill_list, list) {
+ /* # TODO: check why this if clause is needed at all. */
if ((vector != NULL) && (iobref != NULL)) {
memcpy (((char *)vector) + copied,
fill->vector,
diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c
index 7da877f..1f998cf 100644
--- a/xlators/performance/md-cache/src/md-cache.c
+++ b/xlators/performance/md-cache/src/md-cache.c
@@ -3244,7 +3244,7 @@ mdc_xattr_list_populate (struct mdc_conf *conf, char *tmp_str)
"user.org.netatalk.ResourceFork")
+ strlen (tmp_str) + 5; /*Some buffer bytes*/
- mdc_xattr_str = GF_CALLOC (1, max_size, gf_common_mt_char);
+ mdc_xattr_str = GF_MALLOC (max_size, gf_common_mt_char);
GF_CHECK_ALLOC (mdc_xattr_str, ret, out);
if (conf->cache_capability)
diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c
index 8d39720..0946096 100644
--- a/xlators/performance/quick-read/src/quick-read.c
+++ b/xlators/performance/quick-read/src/quick-read.c
@@ -414,7 +414,7 @@ qr_content_extract (dict_t *xdata)
if (ret < 0 || !data)
return NULL;
- content = GF_CALLOC (1, data->len, gf_qr_mt_content_t);
+ content = GF_MALLOC (data->len, gf_qr_mt_content_t);
if (!content)
goto out;
diff --git a/xlators/protocol/client/src/client-lk.c b/xlators/protocol/client/src/client-lk.c
index b5e11aa..4851252 100644
--- a/xlators/protocol/client/src/client-lk.c
+++ b/xlators/protocol/client/src/client-lk.c
@@ -158,7 +158,7 @@ subtract_locks (client_posix_lock_t *big, client_posix_lock_t *small)
if ((big->fl_start == small->fl_start) &&
(big->fl_end == small->fl_end)) {
/* both edges coincide with big */
- v.locks[0] = GF_CALLOC (1, sizeof (client_posix_lock_t),
+ v.locks[0] = GF_MALLOC (sizeof (client_posix_lock_t),
gf_client_mt_clnt_lock_t );
GF_ASSERT (v.locks[0]);
memcpy (v.locks[0], big, sizeof (client_posix_lock_t));
@@ -167,54 +167,49 @@ subtract_locks (client_posix_lock_t *big, client_posix_lock_t *small)
else if ((small->fl_start > big->fl_start) &&
(small->fl_end < big->fl_end)) {
/* both edges lie inside big */
- v.locks[0] = GF_CALLOC (1, sizeof (client_posix_lock_t),
+ v.locks[0] = GF_MALLOC (sizeof (client_posix_lock_t),
gf_client_mt_clnt_lock_t);
GF_ASSERT (v.locks[0]);
- v.locks[1] = GF_CALLOC (1, sizeof (client_posix_lock_t),
- gf_client_mt_clnt_lock_t);
- GF_ASSERT (v.locks[1]);
- v.locks[2] = GF_CALLOC (1, sizeof (client_posix_lock_t),
- gf_client_mt_clnt_lock_t);
- GF_ASSERT (v.locks[2]);
-
memcpy (v.locks[0], big, sizeof (client_posix_lock_t));
v.locks[0]->fl_end = small->fl_start - 1;
v.locks[0]->user_flock.l_len = __get_lock_length (v.locks[0]->fl_start,
v.locks[0]->fl_end);
-
+ v.locks[1] = GF_MALLOC (sizeof (client_posix_lock_t),
+ gf_client_mt_clnt_lock_t);
+ GF_ASSERT (v.locks[1]);
memcpy (v.locks[1], small, sizeof (client_posix_lock_t));
+ v.locks[2] = GF_MALLOC (sizeof (client_posix_lock_t),
+ gf_client_mt_clnt_lock_t);
+ GF_ASSERT (v.locks[2]);
memcpy (v.locks[2], big, sizeof (client_posix_lock_t));
v.locks[2]->fl_start = small->fl_end + 1;
v.locks[2]->user_flock.l_start = small->fl_end + 1;
}
/* one edge coincides with big */
else if (small->fl_start == big->fl_start) {
- v.locks[0] = GF_CALLOC (1, sizeof (client_posix_lock_t),
+ v.locks[0] = GF_MALLOC (sizeof (client_posix_lock_t),
gf_client_mt_clnt_lock_t);
GF_ASSERT (v.locks[0]);
- v.locks[1] = GF_CALLOC (1, sizeof (client_posix_lock_t),
- gf_client_mt_clnt_lock_t);
- GF_ASSERT (v.locks[1]);
-
memcpy (v.locks[0], big, sizeof (client_posix_lock_t));
v.locks[0]->fl_start = small->fl_end + 1;
v.locks[0]->user_flock.l_start = small->fl_end + 1;
-
+ v.locks[1] = GF_MALLOC (sizeof (client_posix_lock_t),
+ gf_client_mt_clnt_lock_t);
+ GF_ASSERT (v.locks[1]);
memcpy (v.locks[1], small, sizeof (client_posix_lock_t));
}
else if (small->fl_end == big->fl_end) {
- v.locks[0] = GF_CALLOC (1, sizeof (client_posix_lock_t),
+ v.locks[0] = GF_MALLOC (sizeof (client_posix_lock_t),
gf_client_mt_clnt_lock_t);
GF_ASSERT (v.locks[0]);
- v.locks[1] = GF_CALLOC (1, sizeof (client_posix_lock_t),
- gf_client_mt_clnt_lock_t);
- GF_ASSERT (v.locks[1]);
-
memcpy (v.locks[0], big, sizeof (client_posix_lock_t));
v.locks[0]->fl_end = small->fl_start - 1;
v.locks[0]->user_flock.l_len = __get_lock_length (v.locks[0]->fl_start,
v.locks[0]->fl_end);
+ v.locks[1] = GF_MALLOC (sizeof (client_posix_lock_t),
+ gf_client_mt_clnt_lock_t);
+ GF_ASSERT (v.locks[1]);
memcpy (v.locks[1], small, sizeof (client_posix_lock_t));
}
else {
diff --git a/xlators/storage/bd/src/bd.c b/xlators/storage/bd/src/bd.c
index 08dc350..0f4ad16 100644
--- a/xlators/storage/bd/src/bd.c
+++ b/xlators/storage/bd/src/bd.c
@@ -993,10 +993,11 @@ bd_setx_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto out;
}
- param = copy = GF_CALLOC (1, local->data->len + 1, gf_common_mt_char);
+ param = copy = GF_MALLOC (local->data->len + 1, gf_common_mt_char);
BD_VALIDATE_MEM_ALLOC (param, op_errno, out);
strncpy (param, local->data->data, local->data->len);
+ param[local->data->len] = '\0';
type = strtok_r (param, ":", &p);
if (!type) {
@@ -1292,7 +1293,7 @@ bd_offload (call_frame_t *frame, xlator_t *this, loc_t *loc,
int op_errno = 0;
bd_local_t *local = frame->local;
- param = GF_CALLOC (1, local->data->len + 1, gf_common_mt_char);
+ param = GF_MALLOC (local->data->len + 1, gf_common_mt_char);
BD_VALIDATE_MEM_ALLOC (param, op_errno, out);
param_copy = param;
@@ -1303,6 +1304,7 @@ bd_offload (call_frame_t *frame, xlator_t *this, loc_t *loc,
BD_VALIDATE_MEM_ALLOC (local->dloc, op_errno, out);
strncpy (param, local->data->data, local->data->len);
+ param[local->data->len] = '\0';
gfid = strtok_r (param, ":", &p);
size = strtok_r (NULL, ":", &p);
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index b4d433e..bd5b6e6 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -272,18 +272,21 @@ _posix_xattr_get_set_from_backend (posix_xattr_filler_t *filler, char *key)
}
if (xattr_size != -1) {
- value = GF_CALLOC (1, xattr_size + 1, gf_posix_mt_char);
+ value = GF_MALLOC (xattr_size + 1, gf_posix_mt_char);
if (!value)
goto out;
if (have_val) {
memcpy (value, val_buf, xattr_size);
- } else if (filler->real_path) {
- xattr_size = sys_lgetxattr (filler->real_path, key,
- value, xattr_size);
} else {
- xattr_size = sys_fgetxattr (filler->fdnum, key, value,
- xattr_size);
+ bzero(value, xattr_size + 1);
+ if (filler->real_path) {
+ xattr_size = sys_lgetxattr (filler->real_path,
+ key, value, xattr_size);
+ } else {
+ xattr_size = sys_fgetxattr (filler->fdnum, key,
+ value, xattr_size);
+ }
}
if (xattr_size == -1) {
if (filler->real_path)
@@ -2518,7 +2521,7 @@ posix_fetch_signature_xattr (char *real_path,
gf_boolean_t have_val = _gf_false;
xattrsize = sys_lgetxattr (real_path, key, val_buf,
- sizeof(val_buf) - 1);
+ sizeof(val_buf) - 1);
if (xattrsize >= 0) {
have_val = _gf_true;
} else {
@@ -2529,12 +2532,14 @@ posix_fetch_signature_xattr (char *real_path,
if (xattrsize == -1)
goto error_return;
}
- memptr = GF_CALLOC (xattrsize + 1, sizeof (char), gf_posix_mt_char);
+ memptr = GF_MALLOC (xattrsize + 1, gf_posix_mt_char);
if (!memptr)
goto error_return;
if (have_val) {
memcpy (memptr, val_buf, xattrsize);
+ memptr[xattrsize] = '\0';
} else {
+ bzero (memptr, xattrsize + 1);
ret = sys_lgetxattr (real_path, key, memptr, xattrsize);
if (ret == -1)
goto freemem;
@@ -2881,7 +2886,7 @@ posix_set_iatt_in_dict (dict_t *dict, struct iatt *preop, struct iatt *postop)
return ret;
if (postop) {
- stbuf = GF_CALLOC (1, len, gf_common_mt_char);
+ stbuf = GF_MALLOC (len, gf_common_mt_char);
if (!stbuf)
goto out;
memcpy (stbuf, postop, len);
@@ -2894,7 +2899,7 @@ posix_set_iatt_in_dict (dict_t *dict, struct iatt *preop, struct iatt *postop)
}
if (preop) {
- prebuf = GF_CALLOC (1, len, gf_common_mt_char);
+ prebuf = GF_MALLOC (len, gf_common_mt_char);
if (!prebuf)
goto out;
memcpy (prebuf, preop, len);
@@ -2906,7 +2911,7 @@ posix_set_iatt_in_dict (dict_t *dict, struct iatt *preop, struct iatt *postop)
}
if (postop) {
- postbuf = GF_CALLOC (1, len, gf_common_mt_char);
+ postbuf = GF_MALLOC (len, gf_common_mt_char);
if (!postbuf)
goto out;
memcpy (postbuf, postop, len);
diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c
index 8935575..ed5f439 100644
--- a/xlators/storage/posix/src/posix-inode-fd-ops.c
+++ b/xlators/storage/posix/src/posix-inode-fd-ops.c
@@ -3224,7 +3224,7 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
goto out;
}
}
- value = GF_CALLOC (size + 1, sizeof(char), gf_posix_mt_char);
+ value = GF_MALLOC (size + 1, gf_posix_mt_char);
if (!value) {
op_ret = -1;
op_errno = ENOMEM;
@@ -3233,6 +3233,7 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
if (have_val) {
memcpy (value, value_buf, size);
} else {
+ bzero (value, size + 1);
size = sys_lgetxattr (real_path, key, value, size);
if (size == -1) {
op_ret = -1;
@@ -3349,8 +3350,7 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
goto out;
}
}
- value = GF_CALLOC (size + 1, sizeof(char),
- gf_posix_mt_char);
+ value = GF_MALLOC (size + 1, gf_posix_mt_char);
if (!value) {
op_errno = errno;
goto out;
@@ -3358,6 +3358,7 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
if (have_val) {
memcpy (value, value_buf, size);
} else {
+ bzero(value, size + 1);
size = sys_lgetxattr (real_path, keybuffer, value, size);
if (size == -1) {
op_errno = errno;
@@ -3533,7 +3534,7 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
goto done;
}
}
- value = GF_CALLOC (size + 1, sizeof(char), gf_posix_mt_char);
+ value = GF_MALLOC (size + 1, gf_posix_mt_char);
if (!value) {
op_ret = -1;
op_errno = ENOMEM;
@@ -3542,6 +3543,7 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
if (have_val) {
memcpy (value, value_buf, size);
} else {
+ bzero (value, size + 1);
size = sys_fgetxattr (_fd, key, value, size);
if (size == -1) {
op_ret = -1;
@@ -3639,8 +3641,7 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
break;
}
}
- value = GF_CALLOC (size + 1, sizeof(char),
- gf_posix_mt_char);
+ value = GF_MALLOC (size + 1, gf_posix_mt_char);
if (!value) {
op_ret = -1;
op_errno = errno;
@@ -3649,6 +3650,7 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
if (have_val) {
memcpy (value, value_buf, size);
} else {
+ bzero (value, size + 1);
size = sys_fgetxattr (_fd, key, value, size);
if (size == -1) {
op_ret = -1;
@@ -5046,11 +5048,12 @@ posix_readdirp_fill (xlator_t *this, fd_t *fd, gf_dirent_t *entries, dict_t *dic
hpath[len] = '/';
list_for_each_entry (entry, &entries->list, list) {
- memset (gfid, 0, 16);
inode = inode_grep (fd->inode->table, fd->inode,
entry->d_name);
if (inode)
gf_uuid_copy (gfid, inode->gfid);
+ else
+ bzero(gfid, 16);
strcpy (&hpath[len+1], entry->d_name);