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_dump.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'utils/conntrack_dump.c') diff --git a/utils/conntrack_dump.c b/utils/conntrack_dump.c index d8ae4f1..4ef9168 100644 --- a/utils/conntrack_dump.c +++ b/utils/conntrack_dump.c @@ -32,10 +32,13 @@ int main() nfct_callback_register(h, NFCT_T_ALL, cb, NULL); ret = nfct_query(h, NFCT_Q_DUMP, &family); - printf("TEST: dump conntrack (%d)(%s)\n", ret, strerror(errno)); - + printf("TEST: get 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