diff options
author | Michael Mann <mmann78@netscape.net> | 2016-07-14 20:28:41 -0400 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2016-07-15 01:49:09 +0000 |
commit | f2a7594ac04adc4c08c26136e779c40ee0f1a7c1 (patch) | |
tree | 3b7ce9f25038392d279f372acc88110270058420 /epan/reassemble_test.c | |
parent | 2c3127940ad65ce503dba1308549719e57f87458 (diff) | |
download | wireshark-f2a7594ac04adc4c08c26136e779c40ee0f1a7c1.tar.gz wireshark-f2a7594ac04adc4c08c26136e779c40ee0f1a7c1.tar.bz2 wireshark-f2a7594ac04adc4c08c26136e779c40ee0f1a7c1.zip |
reassemble_test.c: Reorder macro behavior to make it clearer we have NULL checks in place.
Trying to pacify VS Code Analysis.
Change-Id: I76379b23a5d4c772b91d6113af3974e105e4da88
Reviewed-on: https://code.wireshark.org/review/16448
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/reassemble_test.c')
-rw-r--r-- | epan/reassemble_test.c | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/epan/reassemble_test.c b/epan/reassemble_test.c index 4b7d4eba07..af40f844a4 100644 --- a/epan/reassemble_test.c +++ b/epan/reassemble_test.c @@ -1,4 +1,5 @@ -/* Standalone program to test functionality of reassemble.h API +/* reassemble_test.c + * Standalone program to test functionality of reassemble.h API * * These aren't particularly complete - they just test a few corners of * functionality which I was interested in. In particular, they only test the @@ -59,31 +60,29 @@ #include <epan/tvbuff.h> #include <epan/reassemble.h> -#define ASSERT(b) do_test((b),"Assertion failed at line %i: %s\n", __LINE__, #b) -#define ASSERT_EQ(exp,act) do_test((exp)==(act),"Assertion failed at line %i: %s==%s (%i==%i)\n", __LINE__, #exp, #act, exp, act) -#define ASSERT_NE(exp,act) do_test((exp)!=(act),"Assertion failed at line %i: %s!=%s (%i!=%i)\n", __LINE__, #exp, #act, exp, act) - static int failure = 0; -static void -do_test(gboolean condition, const char *format, ...) -{ - va_list ap; +#define ASSERT(b) \ + if (!(b)) { \ + failure = 1; \ + printf("Assertion failed at line %i: %s\n", __LINE__, #b); \ + exit(1); \ + } - if (condition) - return; +#define ASSERT_EQ(exp,act) \ + if ((exp)!=(act)) { \ + failure = 1; \ + printf("Assertion failed at line %i: %s==%s (%i==%i)\n", __LINE__, #exp, #act, exp, act); \ + exit(1); \ + } - va_start(ap, format); - vfprintf(stderr, format, ap); - va_end(ap); - failure = 1; +#define ASSERT_NE(exp,act) \ + if ((exp)==(act)) { \ + failure = 1; \ + printf("Assertion failed at line %i: %s!=%s (%i!=%i)\n", __LINE__, #exp, #act, exp, act); \ + exit(1); \ + } - /* many of the tests assume this routine doesn't return on failure; if we - * do, it may provide more information, but may cause a segfault. Uncomment - * this line if you wish. - */ - exit(1); -} #define DATA_LEN 256 |