diff options
author | Yann Collet <cyan@fb.com> | 2016-11-14 15:10:31 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2016-11-14 15:10:31 (GMT) |
commit | 1b24cc115595f7cd2f8f5f6de0a9d44a70bdf827 (patch) | |
tree | 85faf2952179862335e122572e52584625f3b9da /tests | |
parent | ecc55d19ba7ce083899459ebbe4b14c109e2bea9 (diff) | |
download | lz4-1b24cc115595f7cd2f8f5f6de0a9d44a70bdf827.zip lz4-1b24cc115595f7cd2f8f5f6de0a9d44a70bdf827.tar.gz lz4-1b24cc115595f7cd2f8f5f6de0a9d44a70bdf827.tar.bz2 |
fixed conversion warnings
Diffstat (limited to 'tests')
-rw-r--r-- | tests/frametest.c | 26 | ||||
-rw-r--r-- | tests/fuzzer.c | 16 |
2 files changed, 20 insertions, 22 deletions
diff --git a/tests/frametest.c b/tests/frametest.c index d4afc58..a99728f 100644 --- a/tests/frametest.c +++ b/tests/frametest.c @@ -139,10 +139,10 @@ unsigned int FUZ_rand(unsigned int* src) #define FUZ_RAND15BITS (FUZ_rand(seed) & 0x7FFF) #define FUZ_RANDLENGTH ( (FUZ_rand(seed) & 3) ? (FUZ_rand(seed) % 15) : (FUZ_rand(seed) % 510) + 15) -static void FUZ_fillCompressibleNoiseBuffer(void* buffer, unsigned bufferSize, double proba, U32* seed) +static void FUZ_fillCompressibleNoiseBuffer(void* buffer, size_t bufferSize, double proba, U32* seed) { BYTE* BBuffer = (BYTE*)buffer; - unsigned pos = 0; + size_t pos = 0; U32 P32 = (U32)(32768 * proba); /* First Byte */ @@ -152,20 +152,18 @@ static void FUZ_fillCompressibleNoiseBuffer(void* buffer, unsigned bufferSize, d /* Select : Literal (noise) or copy (within 64K) */ if (FUZ_RAND15BITS < P32) { /* Copy (within 64K) */ - unsigned match, end; - unsigned length = FUZ_RANDLENGTH + 4; - unsigned offset = FUZ_RAND15BITS + 1; - if (offset > pos) offset = pos; - if (pos + length > bufferSize) length = bufferSize - pos; - match = pos - offset; - end = pos + length; + size_t const lengthRand = FUZ_RANDLENGTH + 4; + size_t const length = MIN(lengthRand, bufferSize - pos); + size_t const end = pos + length; + size_t const offsetRand = FUZ_RAND15BITS + 1; + size_t const offset = MIN(offsetRand, pos); + size_t match = pos - offset; while (pos < end) BBuffer[pos++] = BBuffer[match++]; } else { /* Literal (noise) */ - unsigned end; - unsigned length = FUZ_RANDLENGTH; - if (pos + length > bufferSize) length = bufferSize - pos; - end = pos + length; + size_t const lengthRand = FUZ_RANDLENGTH + 4; + size_t const length = MIN(lengthRand, bufferSize - pos); + size_t const end = pos + length; while (pos < end) BBuffer[pos++] = (BYTE)(FUZ_rand(seed) >> 5); } } @@ -606,7 +604,7 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi /* main fuzzer test loop */ for ( ; (testNb < nbTests) || (clockDuration > FUZ_GetClockSpan(startClock)) ; testNb++) { U32 randState = coreRand ^ prime1; - unsigned const srcBits = (FUZ_rand(&randState) % (FUZ_highbit(srcDataLength-1) - 1)) + 1; + unsigned const srcBits = (FUZ_rand(&randState) % (FUZ_highbit((U32)(srcDataLength-1)) - 1)) + 1; size_t const srcSize = (FUZ_rand(&randState) & ((1<<srcBits)-1)) + 1; size_t const srcStartId = FUZ_rand(&randState) % (srcDataLength - srcSize); const BYTE* const srcStart = (const BYTE*)srcBuffer + srcStartId; diff --git a/tests/fuzzer.c b/tests/fuzzer.c index 4d8d8dd..50f6871 100644 --- a/tests/fuzzer.c +++ b/tests/fuzzer.c @@ -375,23 +375,23 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c /* Test compression HC */ FUZ_DISPLAYTEST; - ret = LZ4_compress_HC(block, compressedBuffer, blockSize, compressedBufferSize, 9); + ret = LZ4_compress_HC(block, compressedBuffer, blockSize, (int)compressedBufferSize, 9); FUZ_CHECKTEST(ret==0, "LZ4_compressHC() failed"); HCcompressedSize = ret; /* Test compression HC using external state */ FUZ_DISPLAYTEST; - ret = LZ4_compress_HC_extStateHC(stateLZ4HC, block, compressedBuffer, blockSize, compressedBufferSize, 9); + ret = LZ4_compress_HC_extStateHC(stateLZ4HC, block, compressedBuffer, blockSize, (int)compressedBufferSize, 9); FUZ_CHECKTEST(ret==0, "LZ4_compressHC_withStateHC() failed"); /* Test compression using external state */ FUZ_DISPLAYTEST; - ret = LZ4_compress_fast_extState(stateLZ4, block, compressedBuffer, blockSize, compressedBufferSize, 9); + ret = LZ4_compress_fast_extState(stateLZ4, block, compressedBuffer, blockSize, (int)compressedBufferSize, 9); FUZ_CHECKTEST(ret==0, "LZ4_compress_withState() failed"); /* Test compression */ FUZ_DISPLAYTEST; - ret = LZ4_compress_default(block, compressedBuffer, blockSize, compressedBufferSize); + ret = LZ4_compress_default(block, compressedBuffer, blockSize, (int)compressedBufferSize); FUZ_CHECKTEST(ret==0, "LZ4_compress() failed"); compressedSize = ret; @@ -531,8 +531,8 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c FUZ_DISPLAYTEST; { LZ4_stream_t LZ4_stream; LZ4_resetStream(&LZ4_stream); - LZ4_compress_fast_continue (&LZ4_stream, dict, compressedBuffer, dictSize, compressedBufferSize, 1); /* Just to fill hash tables */ - blockContinueCompressedSize = LZ4_compress_fast_continue (&LZ4_stream, block, compressedBuffer, blockSize, compressedBufferSize, 1); + LZ4_compress_fast_continue (&LZ4_stream, dict, compressedBuffer, dictSize, (int)compressedBufferSize, 1); /* Just to fill hash tables */ + blockContinueCompressedSize = LZ4_compress_fast_continue (&LZ4_stream, block, compressedBuffer, blockSize, (int)compressedBufferSize, 1); FUZ_CHECKTEST(blockContinueCompressedSize==0, "LZ4_compress_continue failed"); } @@ -561,7 +561,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c dict -= (FUZ_rand(&randState) & 0xF) + 1; /* Separation, so it is an ExtDict */ if (dict < (char*)CNBuffer) dict = (char*)CNBuffer; LZ4_loadDict(&LZ4dict, dict, dictSize); - blockContinueCompressedSize = LZ4_compress_fast_continue(&LZ4dict, block, compressedBuffer, blockSize, compressedBufferSize, 1); + blockContinueCompressedSize = LZ4_compress_fast_continue(&LZ4dict, block, compressedBuffer, blockSize, (int)compressedBufferSize, 1); FUZ_CHECKTEST(blockContinueCompressedSize==0, "LZ4_compress_continue failed"); FUZ_DISPLAYTEST; @@ -620,7 +620,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c if (dict < (char*)CNBuffer) dict = (char*)CNBuffer; LZ4_resetStreamHC (&LZ4dictHC, FUZ_rand(&randState) & 0x7); LZ4_loadDictHC(&LZ4dictHC, dict, dictSize); - blockContinueCompressedSize = LZ4_compress_HC_continue(&LZ4dictHC, block, compressedBuffer, blockSize, compressedBufferSize); + blockContinueCompressedSize = LZ4_compress_HC_continue(&LZ4dictHC, block, compressedBuffer, blockSize, (int)compressedBufferSize); FUZ_CHECKTEST(blockContinueCompressedSize==0, "LZ4_compressHC_continue failed"); FUZ_DISPLAYTEST; |