[Drbd-dev] [PATCH 06/17] lru_cache: use kcalloc instead of kzalloc with multiply

Tobin C. Harding me at tobin.cc
Mon Oct 2 00:34:05 CEST 2017


checkpatch emits WARNING: Prefer kcalloc over kzalloc with multiply.

Use kcalloc instead of kzalloc with multiply.

Signed-off-by: Tobin C. Harding <me at tobin.cc>
---
 lib/lru_cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/lru_cache.c b/lib/lru_cache.c
index 0bdb858..18043b9 100644
--- a/lib/lru_cache.c
+++ b/lib/lru_cache.c
@@ -117,7 +117,7 @@ struct lru_cache *lc_create(const char *name, struct kmem_cache *cache,
 	slot = kcalloc(e_count, sizeof(struct hlist_head), GFP_KERNEL);
 	if (!slot)
 		goto out_fail;
-	element = kzalloc(e_count * sizeof(struct lc_element *), GFP_KERNEL);
+	element = kcalloc(e_count, sizeof(struct lc_element *), GFP_KERNEL);
 	if (!element)
 		goto out_fail;
 
-- 
2.7.4



More information about the drbd-dev mailing list