From f44b2b59ec22903d98395a0543502551f9685e4d Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Wed, 10 Dec 2008 22:50:23 +0100 Subject: utils: fix wrong use of errno in example files This patch removes the use of strerr(errno) when the returned valued is != -1. This fixes random segfaults in my x86_64 machines. According to the documentation, errno should not be used unless the returned value is -1. This patch also includes some missing nfct_close() calls in the examples. Signed-off-by: Pablo Neira Ayuso --- utils/conntrack_flush.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'utils/conntrack_flush.c') diff --git a/utils/conntrack_flush.c b/utils/conntrack_flush.c index 43e8d78..92aac86 100644 --- a/utils/conntrack_flush.c +++ b/utils/conntrack_flush.c @@ -19,10 +19,13 @@ int main() ret = nfct_query(h, NFCT_Q_FLUSH, &family); - printf("TEST: flush conntrack (%d)(%s)\n", ret, strerror(errno)); - + printf("TEST: flush conntrack "); if (ret == -1) - exit(EXIT_FAILURE); + printf("(%d)(%s)\n", ret, strerror(errno)); + else + printf("(OK)\n"); nfct_close(h); + + ret == -1 ? exit(EXIT_FAILURE) : exit(EXIT_SUCCESS); } -- cgit v1.2.3