Skip to contentSkip to conversation

mbuf: cleanup rte_pktmbuf_lastseg(), remove useless variable

PATCH In review Ilya Matveychikov 4 participants 8 messages Nov 14, 2017 – Jan 11, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mbuf: cleanup rte_pktmbuf_lastseg(), remove useless variable

Fixes af75078fece3 ("first public release")
Cc intel.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(-)
lib/librte_mbuf/rte_mbuf.h +3 -5
index 7e326bbc2..be79e3728 100644
@@ -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

#1 lore raw

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:[email protected]] On Behalf Of Ilya Matveychikov
Sent: Tuesday, November 14, 2017 3:45 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH] mbuf: cleanup rte_pktmbuf_lastseg(), remove useless variable

Fixes af75078fece3 ("first public release")
Cc intel.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(-)
lib/librte_mbuf/rte_mbuf.h +3 -6
@@ -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

#2 lore raw
Quoted 14 lines · Hanoch Haim (hhaim)

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?

#3 lore raw
In reply to Ilya Matveychikov

Hi Ilya,

Quoted 2 lines · Ilya Matveychikov
Fixes af75078fece3 ("first public release")
Cc intel.com

The Cc tag seems wrong, should be removed.

Quoted 4 lines

---

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

Yes, you're right. Can you please say it in the commit log?

Thanks,
Olivier

Quoted 26 lines
 lib/librte_mbuf/rte_mbuf.h | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
lib/librte_mbuf/rte_mbuf.h +3 -6
index 7e326bbc2..be79e3728 100644
@@ -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

#4 lore raw

PATCH v2 1/1 mbuf: cleanup rte_pktmbuf_lastseg function

In reply to Ilya Matveychikov

There is no reason to have local variable m2.

Fixes af75078fece3 ("first public release")
---
 lib/librte_mbuf/rte_mbuf.h | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
lib/librte_mbuf/rte_mbuf.h +3 -5
index ce8a05ddf..e4e3917f6 100644
@@ -1541,12 +1541,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;
 }
 
 /**
Signature · 1 line
2.14.2
#6 lore raw

Re: [PATCH v2] mbuf: cleanup rte_pktmbuf_lastseg function

Quoted 7 lines · Olivier MATZ
Quoted 4 lines · Ilya V. Matveychikov

There is no reason to have local variable m2.

Fixes af75078fece3 ("first public release")

Just realized the title does not match ./devtools/check-git-log.sh constraints. I suggest instead:

mbuf: cleanup function to get last segment

#7 lore raw

Re: [PATCH v2] mbuf: cleanup rte_pktmbuf_lastseg function

14/12/2017 10:30, Olivier MATZ:

Quoted 7 lines · Olivier MATZ
Quoted 6 lines · Ilya V. Matveychikov
Quoted 4 lines

There is no reason to have local variable m2.

Fixes af75078fece3 ("first public release")
Quoted 6 lines
Quoted 1 line

Just realized the title does not match ./devtools/check-git-log.sh constraints. I suggest instead:

mbuf: cleanup function to get last segment

Applied, thanks