[dpdk-dev] mbuf: cleanup rte_pktmbuf_lastseg(), remove useless variable

Message ID c09a80d037c2438f9fb4dc5c012a4b4d@XCH-RTP-017.cisco.com (mailing list archive)
State Not Applicable, archived
Delegated to: Thomas Monjalon
Headers

Checks

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

Commit Message

Hanoch Haim (hhaim) Nov. 14, 2017, 8:32 p.m. UTC
  I would add this too 

-  } else if (rte_atomic16_add_return(&m->refcnt_atomic, -1) == 0)

Should be :

+ } else if (likely(rte_mbuf_refcnt_update(m, -1) == 0)) {


Hanoh


-----Original Message-----
From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ilya Matveychikov
Sent: Tuesday, November 14, 2017 3:45 PM
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] mbuf: cleanup rte_pktmbuf_lastseg(), remove useless variable

Fixes: af75078fece3 ("first public release")
Cc: intel.com

Signed-off-by: Ilya V. Matveychikov <matvejchikov@gmail.com>
---

There is no reason to have local variable m2 or am I wrong?

 lib/librte_mbuf/rte_mbuf.h | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
  

Comments

Ilya Matveychikov Nov. 14, 2017, 8:50 p.m. UTC | #1
> On Nov 15, 2017, at 12:32 AM, Hanoch Haim (hhaim) <hhaim@cisco.com> wrote:
> 
> I would add this too 
> 
> -  } else if (rte_atomic16_add_return(&m->refcnt_atomic, -1) == 0)
> 
> Should be :
> 
> + } else if (likely(rte_mbuf_refcnt_update(m, -1) == 0)) {
> 
> 
> Hanoh
> 

Why not to send the separate patch for the change?
  

Patch

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 7e326bbc2..be79e3728 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -1538,12 +1538,10 @@  static inline uint16_t rte_pktmbuf_tailroom(const struct rte_mbuf *m)
  */
 static inline struct rte_mbuf *rte_pktmbuf_lastseg(struct rte_mbuf *m)  {
-	struct rte_mbuf *m2 = (struct rte_mbuf *)m;
-
 	__rte_mbuf_sanity_check(m, 1);
-	while (m2->next != NULL)
-		m2 = m2->next;
-	return m2;
+	while (m->next != NULL)
+		m = m->next;
+	return m;
 }

 /**
--
2.15.0