From: Stephen Hemminger Date: Sat, 14 Feb 2015 14:59:05 +0000 (-0500) Subject: app/test: remove unneeded casts X-Git-Tag: spdx-start~9493 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=f2cae314c3d3bf05060012b191dceb79e49061e8;p=dpdk.git app/test: remove unneeded casts The malloc family returns void * and therefore cast is unnecessary. Use calloc rather than zmalloc with multiply for array. Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson --- diff --git a/app/test/test_hash_perf.c b/app/test/test_hash_perf.c index 05a88ecaeb..842b218f2d 100644 --- a/app/test/test_hash_perf.c +++ b/app/test/test_hash_perf.c @@ -448,13 +448,13 @@ run_single_tbl_perf_test(const struct rte_hash *h, hash_operation func, /* Initialise */ num_buckets = params->entries / params->bucket_entries; - key = (uint8_t *) rte_zmalloc("hash key", - params->key_len * sizeof(uint8_t), 16); + key = rte_zmalloc("hash key", + params->key_len * sizeof(uint8_t), 16); if (key == NULL) return -1; - bucket_occupancies = (uint32_t *) rte_zmalloc("bucket occupancies", - num_buckets * sizeof(uint32_t), 16); + bucket_occupancies = rte_calloc("bucket occupancies", + num_buckets, sizeof(uint32_t), 16); if (bucket_occupancies == NULL) { rte_free(key); return -1; diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c index 303d2b35fc..de85c9ce5d 100644 --- a/app/test/test_mempool.c +++ b/app/test/test_mempool.c @@ -360,7 +360,7 @@ test_mempool_basic_ex(struct rte_mempool * mp) if (mp == NULL) return ret; - obj = (void **)rte_zmalloc("test_mempool_basic_ex", (MEMPOOL_SIZE * sizeof(void *)), 0); + obj = rte_calloc("test_mempool_basic_ex", MEMPOOL_SIZE , sizeof(void *), 0); if (obj == NULL) { printf("test_mempool_basic_ex fail to rte_malloc\n"); return ret; diff --git a/app/test/test_ring.c b/app/test/test_ring.c index 2cd8e7727b..ce25329231 100644 --- a/app/test/test_ring.c +++ b/app/test/test_ring.c @@ -1259,7 +1259,7 @@ test_ring_basic_ex(void) struct rte_ring * rp; void **obj = NULL; - obj = (void **)rte_zmalloc("test_ring_basic_ex_malloc", (RING_SIZE * sizeof(void *)), 0); + obj = rte_calloc("test_ring_basic_ex_malloc", RING_SIZE, sizeof(void *), 0); if (obj == NULL) { printf("test_ring_basic_ex fail to rte_malloc\n"); goto fail_test;