[dpdk-dev] lib/librte_mbuf: remove void * pointer cast

Message ID 20180119091240.25085-1-zhiyong.yang@intel.com (mailing list archive)
State Superseded, archived
Headers

Checks

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

Commit Message

Yang, Zhiyong Jan. 19, 2018, 9:12 a.m. UTC
  It is unnecessary to cast from void * to struct rte_mbuf *,
the change can make code more simple.

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

Comments

Thomas Monjalon Jan. 19, 2018, 9:37 a.m. UTC | #1
Hi Zhiyong,

3 comments about patch formatting:

1/ the title must follow the convention seen in the git history.
If you use git log --oneline lib/librte_mbuf
you will see that it must start with "mbuf:"

2/ The * character does not play well when patch saved in a file,
and it is useless: "void pointer" is correct for understanding.

3/ You must Cc the maintainer as described in MAINTAINERS.
You can use devtools/get-maintainer.sh.
Here, I Cc Olivier.

Thanks


19/01/2018 10:12, Zhiyong Yang:
> It is unnecessary to cast from void * to struct rte_mbuf *,
> the change can make code more simple.
> 
> Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
  
Yang, Zhiyong Jan. 19, 2018, 10:01 a.m. UTC | #2
Thank you, Thomas, I will  do that  according to your comments.

Thanks
Zhiyong

> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Friday, January 19, 2018 5:38 PM
> To: Yang, Zhiyong <zhiyong.yang@intel.com>
> Cc: dev@dpdk.org; Yigit, Ferruh <ferruh.yigit@intel.com>;
> olivier.matz@6wind.com
> Subject: Re: [PATCH] lib/librte_mbuf: remove void * pointer cast
> 
> Hi Zhiyong,
> 
> 3 comments about patch formatting:
> 
> 1/ the title must follow the convention seen in the git history.
> If you use git log --oneline lib/librte_mbuf you will see that it must start with
> "mbuf:"
> 
> 2/ The * character does not play well when patch saved in a file, and it is
> useless: "void pointer" is correct for understanding.
> 
> 3/ You must Cc the maintainer as described in MAINTAINERS.
> You can use devtools/get-maintainer.sh.
> Here, I Cc Olivier.
> 
> Thanks
> 
> 
> 19/01/2018 10:12, Zhiyong Yang:
> > It is unnecessary to cast from void * to struct rte_mbuf *, the change
> > can make code more simple.
> >
> > Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
  
Yang, Zhiyong Jan. 19, 2018, 10:05 a.m. UTC | #3
Drop this one since the patch doesn't follow the convention. I will resend another new one.

Thanks
Zhiyong

> -----Original Message-----
> From: Yang, Zhiyong
> Sent: Friday, January 19, 2018 5:13 PM
> To: dev@dpdk.org
> Cc: thomas@monjalon.net; Yigit, Ferruh <ferruh.yigit@intel.com>; Yang,
> Zhiyong <zhiyong.yang@intel.com>
> Subject: [PATCH] lib/librte_mbuf: remove void * pointer cast
> 
> It is unnecessary to cast from void * to struct rte_mbuf *, the change can
> make code more simple.
> 
> Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
> ---
>  lib/librte_mbuf/rte_mbuf.h | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> 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;
>  }
> --
> 2.13.3
  

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;
 }