app/test: remove unneeded casts
authorStephen Hemminger <stephen@networkplumber.org>
Sat, 14 Feb 2015 14:59:05 +0000 (09:59 -0500)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Wed, 4 Mar 2015 20:51:01 +0000 (21:51 +0100)
The malloc family returns void * and therefore cast is unnecessary.
Use calloc rather than zmalloc with multiply for array.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
app/test/test_hash_perf.c
app/test/test_mempool.c
app/test/test_ring.c

index 05a88ec..842b218 100644 (file)
@@ -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;
index 303d2b3..de85c9c 100644 (file)
@@ -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;
index 2cd8e77..ce25329 100644 (file)
@@ -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;