libnetfilter_conntrack: Add nfct_destroy() to all examples in utils
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().
Signed-off-by Andrew Beverley <[email protected]>
--- 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
Quoted 7 lines · Andrew Beverley
For
libnetfilter_conntrack:
This patch addsnfct_destroy()to all the examples in the utils folder. Although this may be obvious to some, when I wrote my first code usinglibnetfilter_conntract, I used the examples but subsequently missed out all the calls tonfct_destroy().Signed-off-by Andrew Beverley <[email protected]>
Applied, thank you Andrew!