From 0241755dbfce0293fa5d7c5d88ef0ad5365e8362 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 2 Dec 2018 20:12:24 +0700 Subject: Fix clang warnings: -Wformat-pedantic and -Werror=overflow --- tests/fuzzer.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/fuzzer.c b/tests/fuzzer.c index 1d23e1a..9ed3ae9 100644 --- a/tests/fuzzer.c +++ b/tests/fuzzer.c @@ -508,7 +508,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c /* Test decoding with a one byte input */ FUZ_DISPLAYTEST("LZ4_decompress_safe() with one byte input"); - { char const tmp = 0xFF; + { char const tmp = (char)0xFF; LZ4_decompress_safe(&tmp, decodedBuffer, 1, blockSize); } @@ -518,7 +518,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c /* 14 bytes of literals, followed by a 14 byte match. * Should not read beyond the end of the buffer. * See https://github.com/lz4/lz4/issues/508. */ - *tmp = 0xEE; + *tmp = (char)0xEE; memset(tmp + 1, 0, 14); tmp[15] = 14; tmp[16] = 0; @@ -678,7 +678,8 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c FUZ_CHECKTEST(ret>0, "LZ4_compress_fast_continue using ExtDict should fail : one missing byte for output buffer : %i written, %i buffer", ret, blockContinueCompressedSize); FUZ_DISPLAYTEST("test LZ4_compress_fast_continue() with dictionary loaded with LZ4_loadDict()"); - DISPLAYLEVEL(5, " compress %i bytes from buffer(%p) into dst(%p) using dict(%p) of size %i \n", blockSize, block, decodedBuffer, dict, dictSize); + DISPLAYLEVEL(5, " compress %i bytes from buffer(%p) into dst(%p) using dict(%p) of size %i \n", + blockSize, (void *)block, (void *)decodedBuffer, (void *)dict, dictSize); LZ4_loadDict(&LZ4dict, dict, dictSize); ret = LZ4_compress_fast_continue(&LZ4dict, block, compressedBuffer, blockSize, blockContinueCompressedSize, 1); FUZ_CHECKTEST(ret!=blockContinueCompressedSize, "LZ4_compress_limitedOutput_compressed size is different (%i != %i)", ret, blockContinueCompressedSize); @@ -686,7 +687,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c /* Decompress with dictionary as external */ FUZ_DISPLAYTEST("test LZ4_decompress_fast_usingDict() with dictionary as extDict"); - DISPLAYLEVEL(5, " decoding %i bytes from buffer(%p) using dict(%p) of size %i \n", blockSize, decodedBuffer, dict, dictSize); + DISPLAYLEVEL(5, " decoding %i bytes from buffer(%p) using dict(%p) of size %i \n", blockSize, (void *)decodedBuffer, (void *)dict, dictSize); decodedBuffer[blockSize] = 0; ret = LZ4_decompress_fast_usingDict(compressedBuffer, decodedBuffer, blockSize, dict, dictSize); FUZ_CHECKTEST(ret!=blockContinueCompressedSize, "LZ4_decompress_fast_usingDict did not read all compressed block input"); -- cgit v0.12 From b9d3080d75589d5efa70654ac16c83035a756d71 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 2 Dec 2018 20:30:25 +0700 Subject: clang: Fix -Wcast-qual --- tests/fuzzer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/fuzzer.c b/tests/fuzzer.c index 9ed3ae9..fab1fce 100644 --- a/tests/fuzzer.c +++ b/tests/fuzzer.c @@ -679,7 +679,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c FUZ_DISPLAYTEST("test LZ4_compress_fast_continue() with dictionary loaded with LZ4_loadDict()"); DISPLAYLEVEL(5, " compress %i bytes from buffer(%p) into dst(%p) using dict(%p) of size %i \n", - blockSize, (void *)block, (void *)decodedBuffer, (void *)dict, dictSize); + blockSize, (const void *)block, (void *)decodedBuffer, (const void *)dict, dictSize); LZ4_loadDict(&LZ4dict, dict, dictSize); ret = LZ4_compress_fast_continue(&LZ4dict, block, compressedBuffer, blockSize, blockContinueCompressedSize, 1); FUZ_CHECKTEST(ret!=blockContinueCompressedSize, "LZ4_compress_limitedOutput_compressed size is different (%i != %i)", ret, blockContinueCompressedSize); @@ -687,7 +687,8 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c /* Decompress with dictionary as external */ FUZ_DISPLAYTEST("test LZ4_decompress_fast_usingDict() with dictionary as extDict"); - DISPLAYLEVEL(5, " decoding %i bytes from buffer(%p) using dict(%p) of size %i \n", blockSize, (void *)decodedBuffer, (void *)dict, dictSize); + DISPLAYLEVEL(5, " decoding %i bytes from buffer(%p) using dict(%p) of size %i \n", + blockSize, (void *)decodedBuffer, (const void *)dict, dictSize); decodedBuffer[blockSize] = 0; ret = LZ4_decompress_fast_usingDict(compressedBuffer, decodedBuffer, blockSize, dict, dictSize); FUZ_CHECKTEST(ret!=blockContinueCompressedSize, "LZ4_decompress_fast_usingDict did not read all compressed block input"); -- cgit v0.12 From 49073aca8606131bb73ca1471219d63b27d2602f Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 2 Dec 2018 20:39:47 +0700 Subject: clang: Fix -Wcomma --- tests/frametest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/frametest.c b/tests/frametest.c index 6d2cdd0..b93f4fe 100644 --- a/tests/frametest.c +++ b/tests/frametest.c @@ -160,7 +160,7 @@ static unsigned FUZ_highbit(U32 v32) { unsigned nbBits = 0; if (v32==0) return 0; - while (v32) v32 >>= 1, nbBits ++; + while (v32) {v32 >>= 1; nbBits ++;} return nbBits; } -- cgit v0.12