[dpdk-dev,08/11] hash: remove useless casts

Message ID 1437757584-15502-9-git-send-email-stephen@networkplumber.org (mailing list archive)
State Changes Requested, archived
Headers

Commit Message

Stephen Hemminger July 24, 2015, 5:06 p.m. UTC
  Found by coccinelle.

lib/librte_hash/rte_fbk_hash.c:153:7-32: WARNING: casting value returned by memory allocation function to (struct rte_fbk_hash_table *) is useless.
lib/librte_hash/rte_cuckoo_hash.c:218:6-21: WARNING: casting value returned by memory allocation function to (struct rte_hash *) is useless.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_hash/rte_cuckoo_hash.c | 4 ++--
 lib/librte_hash/rte_fbk_hash.c    | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)
  

Patch

diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 5cf4af6..3a4f5e9 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -215,8 +215,8 @@  rte_hash_create(const struct rte_hash_parameters *params)
 		goto err;
 	}
 
-	h = (struct rte_hash *)rte_zmalloc_socket(hash_name, sizeof(struct rte_hash),
-					RTE_CACHE_LINE_SIZE, params->socket_id);
+	h = rte_zmalloc_socket(hash_name, sizeof(struct rte_hash),
+			       RTE_CACHE_LINE_SIZE, params->socket_id);
 
 	if (h == NULL) {
 		RTE_LOG(ERR, HASH, "memory allocation failed\n");
diff --git a/lib/librte_hash/rte_fbk_hash.c b/lib/librte_hash/rte_fbk_hash.c
index 8752a47..4c27756 100644
--- a/lib/librte_hash/rte_fbk_hash.c
+++ b/lib/librte_hash/rte_fbk_hash.c
@@ -150,8 +150,7 @@  rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
 	}
 
 	/* Allocate memory for table. */
-	ht = (struct rte_fbk_hash_table *)rte_zmalloc_socket(hash_name, mem_size,
-			0, params->socket_id);
+	ht = rte_zmalloc_socket(hash_name, mem_size, 0, params->socket_id);
 	if (ht == NULL) {
 		RTE_LOG(ERR, HASH, "Failed to allocate fbk hash table\n");
 		rte_free(te);