From c7968f601a7cd4f54103f63d8db1f1a268c0ec5b Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Thu, 12 Sep 2019 15:19:09 +0300 Subject: afr-common.c, afr-self-heal.h: calloc/alloca0 -> malloc/alloca In 3 cases, there was a memory allocation and zeroing, followed directly by populating it with content. Replaced with memory allocation that did not zero the memory. Change-Id: I4fbb5c924fb3a144e415d2368126b784dde760ea updates: bz#1193929 Signed-off-by: Yaniv Kaul --- xlators/cluster/afr/src/afr-common.c | 2 +- xlators/cluster/afr/src/afr-self-heal.h | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'xlators/cluster/afr/src') diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c index e4737cd33e5..0e5a15092bf 100644 --- a/xlators/cluster/afr/src/afr-common.c +++ b/xlators/cluster/afr/src/afr-common.c @@ -5696,7 +5696,7 @@ afr_local_init(afr_local_t *local, afr_private_t *priv, int32_t *op_errno) goto out; } - local->child_up = GF_CALLOC(priv->child_count, sizeof(*local->child_up), + local->child_up = GF_MALLOC(priv->child_count * sizeof(*local->child_up), gf_afr_mt_char); if (!local->child_up) { if (op_errno) diff --git a/xlators/cluster/afr/src/afr-self-heal.h b/xlators/cluster/afr/src/afr-self-heal.h index 703f80e05cb..55d94e20cea 100644 --- a/xlators/cluster/afr/src/afr-self-heal.h +++ b/xlators/cluster/afr/src/afr-self-heal.h @@ -20,9 +20,8 @@ afr_local_t *__local = frame->local; \ afr_private_t *__priv = frame->this->private; \ int __i = 0, __count = 0; \ - unsigned char *__child_up = NULL; \ + unsigned char *__child_up = alloca(__priv->child_count); \ \ - __child_up = alloca0(__priv->child_count); \ memcpy(__child_up, __priv->child_up, \ sizeof(*__child_up) * __priv->child_count); \ __count = AFR_COUNT(__child_up, __priv->child_count); \ @@ -83,9 +82,9 @@ #define ALLOC_MATRIX(n, type) \ ({ \ - type **__ptr = NULL; \ int __i; \ - __ptr = alloca0(n * sizeof(type *)); \ + type **__ptr = alloca(n * sizeof(type *)); \ + \ for (__i = 0; __i < n; __i++) \ __ptr[__i] = alloca0(n * sizeof(type)); \ __ptr; \ -- cgit