From 73773c6b6a6f4dc96641d1951f3879bae1f7d553 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 27 Sep 2018 18:15:14 -0700 Subject: [PATCH 1/2] fixed legacy compilation tests for some reason, these tests started failing recently on CircleCI --- lib/legacy/zstd_v01.c | 6 ++++++ lib/legacy/zstd_v02.c | 6 ++++++ lib/legacy/zstd_v03.c | 6 ++++++ tests/legacy.c | 5 +++-- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/legacy/zstd_v01.c b/lib/legacy/zstd_v01.c index 6303e1cf..c007e7ce 100644 --- a/lib/legacy/zstd_v01.c +++ b/lib/legacy/zstd_v01.c @@ -668,11 +668,17 @@ static size_t FSE_initDStream(FSE_DStream_t* bitD, const void* srcBuffer, size_t switch(srcSize) { case 7: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[6]) << (sizeof(size_t)*8 - 16); + /* fallthrough */ case 6: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[5]) << (sizeof(size_t)*8 - 24); + /* fallthrough */ case 5: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[4]) << (sizeof(size_t)*8 - 32); + /* fallthrough */ case 4: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[3]) << 24; + /* fallthrough */ case 3: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[2]) << 16; + /* fallthrough */ case 2: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[1]) << 8; + /* fallthrough */ default:; } contain32 = ((const BYTE*)srcBuffer)[srcSize-1]; diff --git a/lib/legacy/zstd_v02.c b/lib/legacy/zstd_v02.c index 8bc0ecee..c09ef8cf 100644 --- a/lib/legacy/zstd_v02.c +++ b/lib/legacy/zstd_v02.c @@ -399,11 +399,17 @@ MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, si switch(srcSize) { case 7: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[6]) << (sizeof(size_t)*8 - 16); + /* fallthrough */ case 6: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[5]) << (sizeof(size_t)*8 - 24); + /* fallthrough */ case 5: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[4]) << (sizeof(size_t)*8 - 32); + /* fallthrough */ case 4: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[3]) << 24; + /* fallthrough */ case 3: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[2]) << 16; + /* fallthrough */ case 2: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[1]) << 8; + /* fallthrough */ default:; } contain32 = ((const BYTE*)srcBuffer)[srcSize-1]; diff --git a/lib/legacy/zstd_v03.c b/lib/legacy/zstd_v03.c index 54445af5..0c4cdf68 100644 --- a/lib/legacy/zstd_v03.c +++ b/lib/legacy/zstd_v03.c @@ -402,11 +402,17 @@ MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, si switch(srcSize) { case 7: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[6]) << (sizeof(size_t)*8 - 16); + /* fallthrough */ case 6: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[5]) << (sizeof(size_t)*8 - 24); + /* fallthrough */ case 5: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[4]) << (sizeof(size_t)*8 - 32); + /* fallthrough */ case 4: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[3]) << 24; + /* fallthrough */ case 3: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[2]) << 16; + /* fallthrough */ case 2: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[1]) << 8; + /* fallthrough */ default:; } contain32 = ((const BYTE*)srcBuffer)[srcSize-1]; diff --git a/tests/legacy.c b/tests/legacy.c index 847e1d25..e1cf82f2 100644 --- a/tests/legacy.c +++ b/tests/legacy.c @@ -36,7 +36,7 @@ size_t const COMPRESSED_SIZE = 917; const char* const EXPECTED; /* content is at end of file */ -int testSimpleAPI(void) +static int testSimpleAPI(void) { size_t const size = strlen(EXPECTED); char* const output = malloc(size); @@ -71,7 +71,8 @@ int testSimpleAPI(void) return 0; } -int testStreamingAPI(void) + +static int testStreamingAPI(void) { size_t const outBuffSize = ZSTD_DStreamOutSize(); char* const outBuff = malloc(outBuffSize); From ff36513556f6484d6570291d90fb25eb4c4f2751 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 27 Sep 2018 18:24:41 -0700 Subject: [PATCH 2/2] fixed longmatch test too --- tests/longmatch.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/longmatch.c b/tests/longmatch.c index ed386157..1271e9ab 100644 --- a/tests/longmatch.c +++ b/tests/longmatch.c @@ -17,25 +17,25 @@ #define ZSTD_STATIC_LINKING_ONLY #include "zstd.h" -int compress(ZSTD_CStream *ctx, ZSTD_outBuffer out, const void *data, size_t size) { +static int +compress(ZSTD_CStream *ctx, ZSTD_outBuffer out, const void *data, size_t size) +{ ZSTD_inBuffer in = { data, size, 0 }; while (in.pos < in.size) { ZSTD_outBuffer tmp = out; const size_t rc = ZSTD_compressStream(ctx, &tmp, &in); - if (ZSTD_isError(rc)) { - return 1; - } + if (ZSTD_isError(rc)) return 1; } - { - ZSTD_outBuffer tmp = out; + { ZSTD_outBuffer tmp = out; const size_t rc = ZSTD_flushStream(ctx, &tmp); if (rc != 0) { return 1; } } return 0; } -int main(int argc, const char** argv) { - ZSTD_CStream *ctx; +int main(int argc, const char** argv) +{ + ZSTD_CStream* ctx; ZSTD_parameters params; size_t rc; unsigned windowLog;