[dpdk-dev] mbuf: remove void pointer cast

Message ID 20180119101813.31450-1-zhiyong.yang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Yang, Zhiyong Jan. 19, 2018, 10:18 a.m. UTC
  It is unnecessary to cast from void * to struct rte_mbuf *,
the change can make code clearer.

Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
---
 lib/librte_mbuf/rte_mbuf.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
  

Comments

Olivier Matz Jan. 22, 2018, 1:07 p.m. UTC | #1
On Fri, Jan 19, 2018 at 06:18:13PM +0800, Zhiyong Yang wrote:
> It is unnecessary to cast from void * to struct rte_mbuf *,
> the change can make code clearer.
> 
> Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>

Acked-by: Olivier Matz <olivier.matz@6wind.com>

Zhihong, for next time please prefix the patch with "PATCH v2"
and use --in-reply-to with the message id of the first version.

Thanks
Olivier
  
Yang, Zhiyong Jan. 23, 2018, 1:15 a.m. UTC | #2
Olivier,

Thanks for your review and Acked-by,  I will do that as you said next time.

Zhiyong

> -----Original Message-----
> From: Olivier Matz [mailto:olivier.matz@6wind.com]
> Sent: Monday, January 22, 2018 9:07 PM
> To: Yang, Zhiyong <zhiyong.yang@intel.com>
> Cc: dev@dpdk.org; Yigit, Ferruh <ferruh.yigit@intel.com>;
> thomas@monjalon.net
> Subject: Re: [PATCH] mbuf: remove void pointer cast
> 
> On Fri, Jan 19, 2018 at 06:18:13PM +0800, Zhiyong Yang wrote:
> > It is unnecessary to cast from void * to struct rte_mbuf *, the change
> > can make code clearer.
> >
> > Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
> 
> Acked-by: Olivier Matz <olivier.matz@6wind.com>
> 
> Zhihong, for next time please prefix the patch with "PATCH v2"
> and use --in-reply-to with the message id of the first version.
> 
> Thanks
> Olivier
  
Thomas Monjalon Jan. 25, 2018, 9:51 p.m. UTC | #3
22/01/2018 14:07, Olivier Matz:
> On Fri, Jan 19, 2018 at 06:18:13PM +0800, Zhiyong Yang wrote:
> > It is unnecessary to cast from void * to struct rte_mbuf *,
> > the change can make code clearer.
> > 
> > Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
> 
> Acked-by: Olivier Matz <olivier.matz@6wind.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index a594e4772..2fd4f5ef9 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -896,11 +896,9 @@  rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header);
 static inline struct rte_mbuf *rte_mbuf_raw_alloc(struct rte_mempool *mp)
 {
 	struct rte_mbuf *m;
-	void *mb = NULL;
 
-	if (rte_mempool_get(mp, &mb) < 0)
+	if (rte_mempool_get(mp, (void **)&m) < 0)
 		return NULL;
-	m = (struct rte_mbuf *)mb;
 	MBUF_RAW_ALLOC_CHECK(m);
 	return m;
 }