DPDK patches and discussions
 help / color / mirror / Atom feed
From: Zhiyong Yang <zhiyong.yang@intel.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com, thomas@monjalon.net,
	Zhiyong Yang <zhiyong.yang@intel.com>
Subject: [dpdk-dev] [PATCH 1/5] lib/librte_lpm: remove unnecessary void * pointer cast
Date: Mon, 15 Jan 2018 15:55:06 +0800	[thread overview]
Message-ID: <20180115075510.29348-2-zhiyong.yang@intel.com> (raw)
In-Reply-To: <20180115075510.29348-1-zhiyong.yang@intel.com>

void * pointer can be assigned to any data type pointer. Unnecessary cast
can be removed in order to keep code clearer.

Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
---
 lib/librte_lpm/rte_lpm.c  | 24 ++++++++++++------------
 lib/librte_lpm/rte_lpm6.c |  4 ++--
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
index 5ba595e22..d464dbda9 100644
--- a/lib/librte_lpm/rte_lpm.c
+++ b/lib/librte_lpm/rte_lpm.c
@@ -99,7 +99,7 @@ rte_lpm_find_existing_v20(const char *name)
 
 	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
 	TAILQ_FOREACH(te, lpm_list, next) {
-		l = (struct rte_lpm_v20 *) te->data;
+		l = te->data;
 		if (strncmp(name, l->name, RTE_LPM_NAMESIZE) == 0)
 			break;
 	}
@@ -125,7 +125,7 @@ rte_lpm_find_existing_v1604(const char *name)
 
 	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
 	TAILQ_FOREACH(te, lpm_list, next) {
-		l = (struct rte_lpm *) te->data;
+		l = te->data;
 		if (strncmp(name, l->name, RTE_LPM_NAMESIZE) == 0)
 			break;
 	}
@@ -174,11 +174,11 @@ rte_lpm_create_v20(const char *name, int socket_id, int max_rules,
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, lpm_list, next) {
-		lpm = (struct rte_lpm_v20 *) te->data;
+		lpm = te->data;
 		if (strncmp(name, lpm->name, RTE_LPM_NAMESIZE) == 0)
 			break;
 	}
-	lpm = NULL;
+
 	if (te != NULL) {
 		rte_errno = EEXIST;
 		goto exit;
@@ -193,7 +193,7 @@ rte_lpm_create_v20(const char *name, int socket_id, int max_rules,
 	}
 
 	/* Allocate memory to store the LPM data structures. */
-	lpm = (struct rte_lpm_v20 *)rte_zmalloc_socket(mem_name, mem_size,
+	lpm = rte_zmalloc_socket(mem_name, mem_size,
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (lpm == NULL) {
 		RTE_LOG(ERR, LPM, "LPM memory allocation failed\n");
@@ -206,7 +206,7 @@ rte_lpm_create_v20(const char *name, int socket_id, int max_rules,
 	lpm->max_rules = max_rules;
 	snprintf(lpm->name, sizeof(lpm->name), "%s", name);
 
-	te->data = (void *) lpm;
+	te->data = lpm;
 
 	TAILQ_INSERT_TAIL(lpm_list, te, next);
 
@@ -250,11 +250,11 @@ rte_lpm_create_v1604(const char *name, int socket_id,
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, lpm_list, next) {
-		lpm = (struct rte_lpm *) te->data;
+		lpm = te->data;
 		if (strncmp(name, lpm->name, RTE_LPM_NAMESIZE) == 0)
 			break;
 	}
-	lpm = NULL;
+
 	if (te != NULL) {
 		rte_errno = EEXIST;
 		goto exit;
@@ -269,7 +269,7 @@ rte_lpm_create_v1604(const char *name, int socket_id,
 	}
 
 	/* Allocate memory to store the LPM data structures. */
-	lpm = (struct rte_lpm *)rte_zmalloc_socket(mem_name, mem_size,
+	lpm = rte_zmalloc_socket(mem_name, mem_size,
 			RTE_CACHE_LINE_SIZE, socket_id);
 	if (lpm == NULL) {
 		RTE_LOG(ERR, LPM, "LPM memory allocation failed\n");
@@ -278,7 +278,7 @@ rte_lpm_create_v1604(const char *name, int socket_id,
 		goto exit;
 	}
 
-	lpm->rules_tbl = (struct rte_lpm_rule *)rte_zmalloc_socket(NULL,
+	lpm->rules_tbl = rte_zmalloc_socket(NULL,
 			(size_t)rules_size, RTE_CACHE_LINE_SIZE, socket_id);
 
 	if (lpm->rules_tbl == NULL) {
@@ -290,7 +290,7 @@ rte_lpm_create_v1604(const char *name, int socket_id,
 		goto exit;
 	}
 
-	lpm->tbl8 = (struct rte_lpm_tbl_entry *)rte_zmalloc_socket(NULL,
+	lpm->tbl8 = rte_zmalloc_socket(NULL,
 			(size_t)tbl8s_size, RTE_CACHE_LINE_SIZE, socket_id);
 
 	if (lpm->tbl8 == NULL) {
@@ -308,7 +308,7 @@ rte_lpm_create_v1604(const char *name, int socket_id,
 	lpm->number_tbl8s = config->number_tbl8s;
 	snprintf(lpm->name, sizeof(lpm->name), "%s", name);
 
-	te->data = (void *) lpm;
+	te->data = lpm;
 
 	TAILQ_INSERT_TAIL(lpm_list, te, next);
 
diff --git a/lib/librte_lpm/rte_lpm6.c b/lib/librte_lpm/rte_lpm6.c
index 45d648571..149677eb1 100644
--- a/lib/librte_lpm/rte_lpm6.c
+++ b/lib/librte_lpm/rte_lpm6.c
@@ -166,7 +166,7 @@ rte_lpm6_create(const char *name, int socket_id,
 	}
 
 	/* Allocate memory to store the LPM data structures. */
-	lpm = (struct rte_lpm6 *)rte_zmalloc_socket(mem_name, (size_t)mem_size,
+	lpm = rte_zmalloc_socket(mem_name, (size_t)mem_size,
 			RTE_CACHE_LINE_SIZE, socket_id);
 
 	if (lpm == NULL) {
@@ -176,7 +176,7 @@ rte_lpm6_create(const char *name, int socket_id,
 		goto exit;
 	}
 
-	lpm->rules_tbl = (struct rte_lpm6_rule *)rte_zmalloc_socket(NULL,
+	lpm->rules_tbl = rte_zmalloc_socket(NULL,
 			(size_t)rules_size, RTE_CACHE_LINE_SIZE, socket_id);
 
 	if (lpm->rules_tbl == NULL) {
-- 
2.13.3

  reply	other threads:[~2018-01-15  8:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-15  7:55 [dpdk-dev] [PATCH 0/5] " Zhiyong Yang
2018-01-15  7:55 ` Zhiyong Yang [this message]
2018-01-15  7:55 ` [dpdk-dev] [PATCH 2/5] lib/librte_efd: remove unnecessary void * pointer cast using rte_zmalloc_socket Zhiyong Yang
2018-01-15  7:55 ` [dpdk-dev] [PATCH 3/5] lib/librte_hash: " Zhiyong Yang
2018-01-15  7:55 ` [dpdk-dev] [PATCH 4/5] lib/librte_member: remove unnecessary void * pointer cast Zhiyong Yang
2018-01-15  7:55 ` [dpdk-dev] [PATCH 5/5] lib/librte_pipeline: remove unnecessary void * pointer cast using rte_zmalloc_socket Zhiyong Yang
2018-01-15 14:29 ` [dpdk-dev] [PATCH 0/5] remove unnecessary void * pointer cast Ferruh Yigit
2018-01-16  0:55   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180115075510.29348-2-zhiyong.yang@intel.com \
    --to=zhiyong.yang@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).