From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 42B18B686 for ; Thu, 19 Feb 2015 15:53:31 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 19 Feb 2015 06:45:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,609,1418112000"; d="scan'208";a="668635291" Received: from bricha3-mobl3.ger.corp.intel.com ([10.243.20.37]) by fmsmga001.fm.intel.com with SMTP; 19 Feb 2015 06:53:16 -0800 Received: by (sSMTP sendmail emulation); Thu, 19 Feb 2015 14:53:15 +0025 Date: Thu, 19 Feb 2015 14:53:15 +0000 From: Bruce Richardson To: Stephen Hemminger Message-ID: <20150219145315.GA700@bricha3-MOBL3> References: <1423925950-5201-1-git-send-email-shemming@brocade.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1423925950-5201-1-git-send-email-shemming@brocade.com> Organization: Intel Shannon Ltd. User-Agent: Mutt/1.5.23 (2014-03-12) Cc: dev@dpdk.org, Stephen Hemminger Subject: Re: [dpdk-dev] [PATCH 1/6] test: remove unneeded casts X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Feb 2015 14:53:31 -0000 On Sat, Feb 14, 2015 at 09:59:05AM -0500, Stephen Hemminger wrote: > The malloc family returns void * and therefore cast is unnecessary. > Use calloc rather than zmalloc with multiply for array. > > Signed-off-by: Stephen Hemminger Looks like a good basic cleanup Acked-by: Bruce Richardson > --- > 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 >