DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/6] test: remove unneeded casts
@ 2015-02-14 14:59 Stephen Hemminger
  2015-02-14 14:59 ` [dpdk-dev] [PATCH 2/6] vhost_xen: remove unnecessary cast Stephen Hemminger
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Stephen Hemminger @ 2015-02-14 14:59 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

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>
---
 app/test/test_hash_perf.c | 8 ++++----
 app/test/test_mempool.c   | 2 +-
 app/test/test_ring.c      | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/app/test/test_hash_perf.c b/app/test/test_hash_perf.c
index be34957..6f719fc 100644
--- a/app/test/test_hash_perf.c
+++ b/app/test/test_hash_perf.c
@@ -459,13 +459,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 303d2b3..de85c9c 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 2cd8e77..ce25329 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;
-- 
2.1.4

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-03-04 20:53 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-14 14:59 [dpdk-dev] [PATCH 1/6] test: remove unneeded casts Stephen Hemminger
2015-02-14 14:59 ` [dpdk-dev] [PATCH 2/6] vhost_xen: remove unnecessary cast Stephen Hemminger
2015-02-19 14:53   ` Bruce Richardson
2015-02-14 14:59 ` [dpdk-dev] [PATCH 3/6] bsd: remove useless assignments Stephen Hemminger
2015-02-16 11:31   ` Bruce Richardson
2015-02-14 14:59 ` [dpdk-dev] [PATCH 4/6] enic: eliminate useless cast Stephen Hemminger
2015-02-19 14:57   ` Bruce Richardson
2015-02-14 14:59 ` [dpdk-dev] [PATCH 5/6] eal: remove useless memset Stephen Hemminger
2015-02-19 14:58   ` Bruce Richardson
2015-02-14 14:59 ` [dpdk-dev] [PATCH 6/6] examples: remove unneeded casts Stephen Hemminger
2015-02-19 15:02   ` Bruce Richardson
2015-02-19 14:53 ` [dpdk-dev] [PATCH 1/6] test: " Bruce Richardson
2015-03-04 20:52   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).