From: Mika T. Lindqvist Date: Thu, 15 Dec 2022 04:51:51 +0000 (+0200) Subject: Tell scan-build ASSERT_TRUE() behaves like assert(). X-Git-Tag: 2.1.0-beta1~121 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06b579a3c46d84aeeb3d104d1d55f5e6bbe92359;p=thirdparty%2Fzlib-ng.git Tell scan-build ASSERT_TRUE() behaves like assert(). --- diff --git a/test/test_aligned_alloc.cc b/test/test_aligned_alloc.cc index 259d474b8..de73c7ec3 100644 --- a/test/test_aligned_alloc.cc +++ b/test/test_aligned_alloc.cc @@ -11,6 +11,8 @@ extern "C" { #include +#include "test_shared.h" + void *zng_calloc_unaligned(void *opaque, unsigned items, unsigned size) { uint8_t *pointer = (uint8_t *)calloc(1, (items * size) + 2); Z_UNUSED(opaque); diff --git a/test/test_compare256.cc b/test/test_compare256.cc index 7c4dab989..663ad9633 100644 --- a/test/test_compare256.cc +++ b/test/test_compare256.cc @@ -15,8 +15,11 @@ extern "C" { #include +#include "test_shared.h" + #define MAX_COMPARE_SIZE (256) + /* Ensure that compare256 returns the correct match length */ static inline void compare256_match_check(compare256_func compare256) { int32_t match_len, i; diff --git a/test/test_compress_bound.cc b/test/test_compress_bound.cc index cd5f6e5b9..d51452b23 100644 --- a/test/test_compress_bound.cc +++ b/test/test_compress_bound.cc @@ -12,10 +12,10 @@ #include #include -#include "test_shared.h" - #include +#include "test_shared.h" + #define MAX_LENGTH (32) class compress_bound_variant : public testing::TestWithParam { diff --git a/test/test_deflate_bound.cc b/test/test_deflate_bound.cc index 27020c6f9..8de65535f 100644 --- a/test/test_deflate_bound.cc +++ b/test/test_deflate_bound.cc @@ -12,10 +12,10 @@ #include #include -#include "test_shared.h" - #include +#include "test_shared.h" + #define MAX_LENGTH (32) typedef struct { diff --git a/test/test_deflate_dict.cc b/test/test_deflate_dict.cc index 7a060a8de..781c70db2 100644 --- a/test/test_deflate_dict.cc +++ b/test/test_deflate_dict.cc @@ -12,10 +12,10 @@ #include #include -#include "test_shared.h" - #include +#include "test_shared.h" + TEST(deflate, dictionary) { PREFIX3(stream) c_stream; uint8_t compr[128]; diff --git a/test/test_deflate_header.cc b/test/test_deflate_header.cc index 92f461208..46d3478c1 100644 --- a/test/test_deflate_header.cc +++ b/test/test_deflate_header.cc @@ -12,10 +12,10 @@ #include #include -#include "test_shared.h" - #include +#include "test_shared.h" + TEST(deflate, header) { PREFIX3(stream) c_stream; PREFIX(gz_header) *head; diff --git a/test/test_deflate_params.cc b/test/test_deflate_params.cc index f5f5066ad..9fadea85f 100644 --- a/test/test_deflate_params.cc +++ b/test/test_deflate_params.cc @@ -16,10 +16,10 @@ #include "deflate.h" -#include "test_shared.h" - #include +#include "test_shared.h" + #define COMPR_BUFFER_SIZE (48 * 1024) #define UNCOMPR_BUFFER_SIZE (64 * 1024) #define UNCOMPR_RAND_SIZE (8 * 1024) diff --git a/test/test_deflate_pending.cc b/test/test_deflate_pending.cc index b107dd43c..8ccedbf33 100644 --- a/test/test_deflate_pending.cc +++ b/test/test_deflate_pending.cc @@ -12,10 +12,10 @@ #include #include -#include "test_shared.h" - #include +#include "test_shared.h" + TEST(deflate, pending) { PREFIX3(stream) c_stream; uint8_t compr[128]; diff --git a/test/test_gzio.cc b/test/test_gzio.cc index 59e46f520..3cab1dbe4 100644 --- a/test/test_gzio.cc +++ b/test/test_gzio.cc @@ -12,10 +12,10 @@ #include #include -#include "test_shared.h" - #include +#include "test_shared.h" + #define TESTFILE "foo.gz" TEST(gzip, readwrite) { diff --git a/test/test_large_buffers.cc b/test/test_large_buffers.cc index 9bf133998..3c1208140 100644 --- a/test/test_large_buffers.cc +++ b/test/test_large_buffers.cc @@ -13,10 +13,10 @@ #include #include -#include "test_shared.h" - #include +#include "test_shared.h" + #define COMPR_BUFFER_SIZE (48 * 1024) #define UNCOMPR_BUFFER_SIZE (32 * 1024) #define UNCOMPR_RAND_SIZE (8 * 1024) diff --git a/test/test_shared.h b/test/test_shared.h index df92a56b3..616f57342 100644 --- a/test/test_shared.h +++ b/test/test_shared.h @@ -9,4 +9,10 @@ static const char hello[] = "hello, hello!"; static const int hello_len = sizeof(hello); +/* Clang static analyzer doesn't understand googletest's ASSERT_TRUE, so we need to tell that it's like assert() */ +#ifdef __clang_analyzer__ +# undef ASSERT_TRUE +# define ASSERT_TRUE assert +#endif + #endif