Skip to contentSkip to conversation

test: remove unneeded null check before free

PATCH In review Stephen Hemminger 2 participants 3 messages Oct 2 – Oct 3

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test: remove unneeded null check before free

Found by devtools/null_free.cocci.

---
 app/test/test_cksum.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
app/test/test_cksum.c +1 -2
index 73f2511731..d94539820a 100644
@@ -320,8 +320,7 @@ test_l4_cksum_mbuf_chain(struct rte_mempool *pktmbuf_pool, const char *pktdata,
 	return 0;
 
 fail:
-	if (m_hdr)
-		rte_pktmbuf_free(m_hdr);
+	rte_pktmbuf_free(m_hdr);
 
 	return -1;
 }
Signature · 1 line
2.53.0
Acked-by on v1 1/1
#1 lore raw
Quoted 1 line · Stephen Hemminger

Found by devtools/null_free.cocci.

nit: should the commit message quote specific coccinelle output being fixed?

Quoted 10 lines
---
  app/test/test_cksum.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
app/test/test_cksum.c +0 -0
index 73f2511731..d94539820a 100644

app/test/test_cksum.c test_l4_cksum_mbuf_chain(struct rte_mempool *pktmbuf_pool, const char *pktdata, · line 326

Quoted 9 lines
app/test/test_cksum.c +1 -2
@@ -320,8 +320,7 @@ test_l4_cksum_mbuf_chain(struct rte_mempool *pktmbuf_pool, const char *pktdata,
  	return 0;
 
  fail:
-	if (m_hdr)
-		rte_pktmbuf_free(m_hdr);
+	rte_pktmbuf_free(m_hdr);
 
  	return -1;
  }
#2 lore raw
Quoted 5 lines · On Sat, 3 Oct 2026 08:25:40 +0100 Marat Khalili <[email protected]> wrote:
Quoted 1 line · Stephen Hemminger

Found by devtools/null_free.cocci.

nit: should the commit message quote specific coccinelle output being fixed?

Coccinelle does edit in place on tree.
./devtools/cocci.sh ./devtools/cocci/null_free.cocci