diff options
author | Yaniv Kaul <ykaul@redhat.com> | 2018-08-04 09:51:26 +0300 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-09-04 04:58:14 +0000 |
commit | 81cbbfd1d870bea49b8aafe7bebb9e8251190918 (patch) | |
tree | 48e02860d8ddc43067ab1836adba90f8a03a14d7 /xlators/performance | |
parent | 4cfbdfd0c851e4a5c6f4303a9141f34f8887b376 (diff) |
Multiple files: calloc -> malloc
xlators/storage/posix/src/posix-inode-fd-ops.c:
xlators/storage/posix/src/posix-helpers.c:
xlators/storage/bd/src/bd.c:
xlators/protocol/client/src/client-lk.c:
xlators/performance/quick-read/src/quick-read.c:
xlators/performance/io-cache/src/page.c
xlators/nfs/server/src/nfs3-helpers.c
xlators/nfs/server/src/nfs-fops.c
xlators/nfs/server/src/mount3udp_svc.c
xlators/nfs/server/src/mount3.c
xlators/mount/fuse/src/fuse-helpers.c
xlators/mount/fuse/src/fuse-bridge.c
xlators/mgmt/glusterd/src/glusterd-utils.c
xlators/mgmt/glusterd/src/glusterd-syncop.h
xlators/mgmt/glusterd/src/glusterd-snapshot.c
xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
xlators/mgmt/glusterd/src/glusterd-replace-brick.c
xlators/mgmt/glusterd/src/glusterd-op-sm.c
xlators/mgmt/glusterd/src/glusterd-mgmt.c
xlators/meta/src/subvolumes-dir.c
xlators/meta/src/graph-dir.c
xlators/features/trash/src/trash.c
xlators/features/shard/src/shard.h
xlators/features/shard/src/shard.c
xlators/features/marker/src/marker-quota.c
xlators/features/locks/src/common.c
xlators/features/leases/src/leases-internal.c
xlators/features/gfid-access/src/gfid-access.c
xlators/features/cloudsync/src/cloudsync-plugins/src/cloudsyncs3/src/libcloudsyncs3.c
xlators/features/bit-rot/src/bitd/bit-rot.c
xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
bxlators/encryption/crypt/src/metadata.c
xlators/encryption/crypt/src/crypt.c
xlators/performance/md-cache/src/md-cache.c:
Move to GF_MALLOC() instead of GF_CALLOC() when possible
It doesn't make sense to calloc (allocate and clear) memory
when the code right away fills that memory with data.
It may be optimized by the compiler, or have a microscopic
performance improvement.
In some cases, also changed allocation size to be sizeof some
struct or type instead of a pointer - easier to read.
In some cases, removed redundant strlen() calls by saving the result
into a variable.
1. Only done for the straightforward cases. There's room for improvement.
2. Please review carefully, especially for string allocation, with the
terminating NULL string.
Only compile-tested!
.. and allocate memory as much as needed.
xlators/nfs/server/src/mount3.c :
Don't blindly allocate PATH_MAX, but strlen() the string and allocate
appropriately.
Also, align error messges.
updates: bz#1193929
Original-Author: Yaniv Kaul <ykaul@redhat.com>
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
Change-Id: Ibda6f33dd180b7f7694f20a12af1e9576fe197f5
Diffstat (limited to 'xlators/performance')
-rw-r--r-- | xlators/performance/io-cache/src/page.c | 1 | ||||
-rw-r--r-- | xlators/performance/md-cache/src/md-cache.c | 2 | ||||
-rw-r--r-- | xlators/performance/quick-read/src/quick-read.c | 2 |
3 files changed, 3 insertions, 2 deletions
diff --git a/xlators/performance/io-cache/src/page.c b/xlators/performance/io-cache/src/page.c index 50f5e190e21..33e728cfc8c 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 7da877f87e2..1f998cfcf21 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 8d39720e7f2..094609684ff 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; |