diff mbox series

[v2,14/83] app/test-regex: remove unnecessary NULL checks

Message ID 20220124174719.14417-15-stephen@networkplumber.org (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series remove unnecessary null checks | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger Jan. 24, 2022, 5:46 p.m. UTC
Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test-regex/main.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/app/test-regex/main.c b/app/test-regex/main.c
index 8e665df73ce0..ab8a3e56e774 100644
--- a/app/test-regex/main.c
+++ b/app/test-regex/main.c
@@ -210,8 +210,7 @@  read_file(char *file, char **buf)
 	printf("Error, can't open file %s\n, err = %d", file, res);
 	if (fp)
 		fclose(fp);
-	if (*buf)
-		rte_free(*buf);
+	rte_free(*buf);
 	return -res;
 }
 
@@ -299,8 +298,7 @@  init_port(uint16_t *nb_max_payload, char *rules_file, uint8_t *nb_max_matches,
 	rte_free(rules);
 	return 0;
 error:
-	if (rules)
-		rte_free(rules);
+	rte_free(rules);
 	return res;
 }
 
@@ -367,8 +365,7 @@  regex_create_segmented_mbuf(struct rte_mempool *mbuf_pool, int pkt_len,
 	return mbuf;
 
 fail:
-	if (mbuf)
-		rte_pktmbuf_free(mbuf);
+	rte_pktmbuf_free(mbuf);
 	return NULL;
 }
 
@@ -612,8 +609,7 @@  run_regex(void *args)
 		rte_free(qp->buf);
 		qp->buf = NULL;
 	}
-	if (mbuf_mp)
-		rte_mempool_free(mbuf_mp);
+	rte_mempool_free(mbuf_mp);
 	rte_free(qps);
 	return res;
 }