From: Victor Julien Date: Mon, 18 Jan 2021 14:50:57 +0000 (+0100) Subject: decode: minor unittest cleanups X-Git-Tag: suricata-7.0.0-beta1~1858 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F5742%2Fhead;p=thirdparty%2Fsuricata.git decode: minor unittest cleanups --- diff --git a/src/decode-chdlc.c b/src/decode-chdlc.c index 6ecb6b44ba..a7ed61869d 100644 --- a/src/decode-chdlc.c +++ b/src/decode-chdlc.c @@ -75,8 +75,7 @@ static int DecodeCHDLCTest01 (void) 0x02,0x04,0x05,0xb4,0x01,0x01,0x04,0x02 }; Packet *p = SCMalloc(SIZE_OF_PACKET); - if (unlikely(p == NULL)) - return 0; + FAIL_IF_NULL(p); ThreadVars tv; DecodeThreadVars dtv; diff --git a/src/decode-gre.c b/src/decode-gre.c index 058c529b85..a55352a733 100644 --- a/src/decode-gre.c +++ b/src/decode-gre.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2020 Open Information Security Foundation +/* Copyright (C) 2007-2021 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -286,8 +286,7 @@ static int DecodeGREtest01 (void) { uint8_t raw_gre[] = { 0x00 ,0x6e ,0x62 }; Packet *p = PacketGetFromAlloc(); - if (unlikely(p == NULL)) - return 0; + FAIL_IF_NULL(p); ThreadVars tv; DecodeThreadVars dtv; @@ -295,14 +294,10 @@ static int DecodeGREtest01 (void) memset(&dtv, 0, sizeof(DecodeThreadVars)); DecodeGRE(&tv, &dtv, p, raw_gre, sizeof(raw_gre)); - - if(ENGINE_ISSET_EVENT(p,GRE_PKT_TOO_SMALL)) { - SCFree(p); - return 1; - } + FAIL_IF_NOT(ENGINE_ISSET_EVENT(p, GRE_PKT_TOO_SMALL)); SCFree(p); - return 0; + PASS; } /** @@ -327,8 +322,7 @@ static int DecodeGREtest02 (void) 0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; Packet *p = PacketGetFromAlloc(); - if (unlikely(p == NULL)) - return 0; + FAIL_IF_NULL(p); ThreadVars tv; DecodeThreadVars dtv; @@ -336,14 +330,10 @@ static int DecodeGREtest02 (void) memset(&dtv, 0, sizeof(DecodeThreadVars)); DecodeGRE(&tv, &dtv, p, raw_gre, sizeof(raw_gre)); - - if(ENGINE_ISSET_EVENT(p,GRE_WRONG_VERSION)) { - SCFree(p); - return 1; - } + FAIL_IF_NOT(ENGINE_ISSET_EVENT(p, GRE_WRONG_VERSION)); SCFree(p); - return 0; + PASS; } @@ -369,8 +359,7 @@ static int DecodeGREtest03 (void) 0x01, 0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; Packet *p = PacketGetFromAlloc(); - if (unlikely(p == NULL)) - return 0; + FAIL_IF_NULL(p); ThreadVars tv; DecodeThreadVars dtv; @@ -378,15 +367,10 @@ static int DecodeGREtest03 (void) memset(&dtv, 0, sizeof(DecodeThreadVars)); DecodeGRE(&tv, &dtv, p, raw_gre, sizeof(raw_gre)); - - if(p->greh == NULL) { - SCFree(p); - return 0; - } - + FAIL_IF_NULL(p->greh); SCFree(p); - return 1; + PASS; } #endif /* UNITTESTS */