Skip to contentSkip to conversation

libnetfilter_conntrack: Add nfct_destroy() to all examples in utils

PATCH Applied Andrew Beverley 2 participants 2 messages Apr 16, 2011 – May 14, 2011 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libnetfilter_conntrack: Add nfct_destroy() to all examples in utils

For libnetfilter_conntrack:
This patch adds nfct_destroy() to all the examples in the utils folder. Although this may be obvious to some, when I wrote my first code using libnetfilter_conntract, I used the examples but subsequently missed out all the calls to nfct_destroy().

---
 utils/conntrack_create.c        |    3 +++
 utils/conntrack_create_nat.c    |    3 +++
 utils/conntrack_delete.c        |    3 +++
 utils/conntrack_get.c           |    3 +++
 utils/conntrack_grp_create.c    |    3 +++
 utils/conntrack_master.c        |    5 +++++
 utils/conntrack_update.c        |    3 +++
 utils/expect_create.c           |    6 ++++++
 utils/expect_create_userspace.c |    7 +++++++
 utils/expect_delete.c           |    6 ++++++
 utils/expect_get.c              |    4 ++++
 11 files changed, 46 insertions(+), 0 deletions(-)
utils/conntrack_create.c +3 -0
index 7140b97..1a81100 100644
@@ -35,6 +35,7 @@ int main(void)
 	h = nfct_open(CONNTRACK, 0);
 	if (!h) {
 		perror("nfct_open");
+		nfct_destroy(ct);
 		return -1;
 	}
 
@@ -48,5 +49,7 @@ int main(void)
 
 	nfct_close(h);
 
+	nfct_destroy(ct);
+
 	ret == -1 ? exit(EXIT_FAILURE) : exit(EXIT_SUCCESS);
 }
utils/conntrack_create_nat.c +3 -0
index f7426ee..b8eb78d 100644
@@ -37,6 +37,7 @@ int main(void)
 	h = nfct_open(CONNTRACK, 0);
 	if (!h) {
 		perror("nfct_open");
+		nfct_destroy(ct);
 		return -1;
 	}
 
@@ -50,5 +51,7 @@ int main(void)
 
 	nfct_close(h);
 
+	nfct_destroy(ct);
+
 	ret == -1 ? exit(EXIT_FAILURE) : exit(EXIT_SUCCESS);
 }
utils/conntrack_delete.c +3 -0
index b3204dd..ae2fc35 100644
@@ -30,6 +30,7 @@ int main(void)
 	h = nfct_open(CONNTRACK, 0);
 	if (!h) {
 		perror("nfct_open");
+		nfct_destroy(ct);
 		return -1;
 	}
 
@@ -43,5 +44,7 @@ int main(void)
 
 	nfct_close(h);
 
+	nfct_destroy(ct);
+
 	ret == -1 ? exit(EXIT_FAILURE) : exit(EXIT_SUCCESS);
 }
utils/conntrack_get.c +3 -0
index 7d7badd..6ddecaf 100644
@@ -42,6 +42,7 @@ int main(void)
 	h = nfct_open(CONNTRACK, 0);
 	if (!h) {
 		perror("nfct_open");
+		nfct_destroy(ct);
 		return -1;
 	}
 
@@ -57,5 +58,7 @@ int main(void)
 
 	nfct_close(h);
 
+	nfct_destroy(ct);
+
 	ret == -1 ? exit(EXIT_FAILURE) : exit(EXIT_SUCCESS);
 }
utils/conntrack_grp_create.c +3 -0
index b47d09a..7ad2f0d 100644
@@ -41,6 +41,7 @@ int main(void)
 	h = nfct_open(CONNTRACK, 0);
 	if (!h) {
 		perror("nfct_open");
+		nfct_destroy(ct);
 		return -1;
 	}
 
@@ -54,5 +55,7 @@ int main(void)
 
 	nfct_close(h);
 
+	nfct_destroy(ct);
+
 	ret == -1 ? exit(EXIT_FAILURE) : exit(EXIT_SUCCESS);
 }
utils/conntrack_master.c +5 -0
index d08219a..a7c7bca 100644
@@ -36,6 +36,7 @@ int main(void)
 	h = nfct_open(CONNTRACK, 0);
 	if (!h) {
 		perror("nfct_open");
+		nfct_destroy(ct);
 		return -1;
 	}
 
@@ -47,6 +48,8 @@ int main(void)
 	else
 		printf("(OK)\n");
 
+	nfct_destroy(ct);
+
 	if (ret == -1)
 		exit(EXIT_FAILURE);
 
@@ -91,5 +94,7 @@ int main(void)
 
 	nfct_close(h);
 
+	nfct_destroy(expected);
+
 	ret == -1 ? exit(EXIT_FAILURE) : exit(EXIT_SUCCESS);
 }
utils/conntrack_update.c +3 -0
index 24545ca..9459a90 100644
@@ -35,6 +35,7 @@ int main(void)
 	h = nfct_open(CONNTRACK, 0);
 	if (!h) {
 		perror("nfct_open");
+		nfct_destroy(ct);
 		return -1;
 	}
 
@@ -48,5 +49,7 @@ int main(void)
 
 	nfct_close(h);
 
+	nfct_destroy(ct);
+
 	ret == -1 ? exit(EXIT_FAILURE) : exit(EXIT_SUCCESS);
 }
utils/expect_create.c +6 -0
index 912ab8e..cf379e9 100644
@@ -46,6 +46,7 @@ int main(void)
 	h = nfct_open(CONNTRACK, 0);
 	if (!h) {
 		perror("nfct_open");
+		nfct_destroy(master);
 		return -1;
 	}
 
@@ -76,6 +77,8 @@ int main(void)
 	mask = nfct_new();
 	if (!mask) {
 		perror("nfct_new");
+		nfct_destroy(master);
+		nfct_destroy(expected);
 		exit(EXIT_FAILURE);
 	}
 
@@ -94,6 +97,9 @@ int main(void)
 	exp = nfexp_new();
 	if (!exp) {
 		perror("nfexp_new");
+		nfct_destroy(master);
+		nfct_destroy(expected);
+		nfct_destroy(mask);
 		exit(EXIT_FAILURE);
 	}
 
utils/expect_create_userspace.c +7 -0
index 0e910e6..8f55a9f 100644
@@ -45,6 +45,7 @@ int main(void)
 	h = nfct_open(CONNTRACK, 0);
 	if (!h) {
 		perror("nfct_open");
+		nfct_destroy(master);
 		return -1;
 	}
 
@@ -66,6 +67,7 @@ int main(void)
 	expected = nfct_new();
 	if (!expected) {
 		perror("nfct_new");
+		nfct_destroy(master);
 		exit(EXIT_FAILURE);
 	}
 
@@ -80,6 +82,8 @@ int main(void)
 	mask = nfct_new();
 	if (!mask) {
 		perror("nfct_new");
+		nfct_destroy(master);
+		nfct_destroy(expected);
 		exit(EXIT_FAILURE);
 	}
 
@@ -98,6 +102,9 @@ int main(void)
 	exp = nfexp_new();
 	if (!exp) {
 		perror("nfexp_new");
+		nfct_destroy(master);
+		nfct_destroy(expected);
+		nfct_destroy(mask);
 		exit(EXIT_FAILURE);
 	}
 
utils/expect_delete.c +6 -0
index 18f4a79..21e4a03 100644
@@ -30,6 +30,7 @@ int main(void)
 	exp = nfexp_new();
 	if (!exp) {
 		perror("nfexp_new");
+		nfct_destroy(expected);
 		exit(EXIT_FAILURE);
 	}
 
@@ -38,6 +39,7 @@ int main(void)
 	h = nfct_open(EXPECT, 0);
 	if (!h) {
 		perror("nfct_open");
+		nfct_destroy(expected);
 		return -1;
 	}
 
@@ -49,5 +51,9 @@ int main(void)
 	else
 		printf("(OK)\n");
 
+	nfct_close(h);
+
+	nfct_destroy(expected);
+
 	ret == -1 ? exit(EXIT_FAILURE) : exit(EXIT_SUCCESS);
 }
utils/expect_get.c +4 -0
index fc7e116..e42c845 100644
@@ -42,6 +42,7 @@ int main(void)
 	exp = nfexp_new();
 	if (!exp) {
 		perror("nfexp_new");
+		nfct_destroy(master);
 		exit(EXIT_FAILURE);
 	}
 
@@ -50,6 +51,7 @@ int main(void)
 	h = nfct_open(EXPECT, 0);
 	if (!h) {
 		perror("nfct_open");
+		nfct_destroy(master);
 		return -1;
 	}
 
@@ -64,5 +66,7 @@ int main(void)
 
 	nfct_close(h);
 
+	nfct_destroy(master);
+
 	ret == -1 ? exit(EXIT_FAILURE) : exit(EXIT_SUCCESS);
 }
Signature · 1 line
1.7.1
maintainer Applied
#1 lore raw
Quoted 7 lines · Andrew Beverley

For libnetfilter_conntrack:
This patch adds nfct_destroy() to all the examples in the utils folder. Although this may be obvious to some, when I wrote my first code using libnetfilter_conntract, I used the examples but subsequently missed out all the calls to nfct_destroy().

Applied, thank you Andrew!