some more minor conversion warnings fixes

This commit is contained in:
Yann Collet 2019-05-29 13:14:52 -07:00
parent c5bcb4d68b
commit 76116495bf
3 changed files with 10 additions and 10 deletions

View File

@ -49,7 +49,7 @@ allmost: lib lz4
.PHONY: lib lib-release liblz4.a .PHONY: lib lib-release liblz4.a
lib: liblz4.a lib: liblz4.a
lib lib-release liblz4.a: lib lib-release liblz4.a:
@$(MAKE) -C $(LZ4DIR) $@ @CFLAGS="$(CFLAGS)" $(MAKE) -C $(LZ4DIR) $@
.PHONY: lz4 lz4-release .PHONY: lz4 lz4-release
lz4 : liblz4.a lz4 : liblz4.a

View File

@ -462,7 +462,7 @@ static unsigned LZ4_NbCommonBytes (reg_t val)
_BitScanForward64( &r, (U64)val ); _BitScanForward64( &r, (U64)val );
return (int)(r>>3); return (int)(r>>3);
# elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT) # elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT)
return (__builtin_ctzll((U64)val) >> 3); return (unsigned)__builtin_ctzll((U64)val) >> 3;
# else # else
static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2, static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2,
0, 3, 1, 3, 1, 4, 2, 7, 0, 3, 1, 3, 1, 4, 2, 7,
@ -480,7 +480,7 @@ static unsigned LZ4_NbCommonBytes (reg_t val)
_BitScanForward( &r, (U32)val ); _BitScanForward( &r, (U32)val );
return (int)(r>>3); return (int)(r>>3);
# elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT) # elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT)
return (__builtin_ctz((U32)val) >> 3); return (unsigned)__builtin_ctz((U32)val) >> 3;
# else # else
static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0, static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0,
3, 2, 2, 1, 3, 2, 0, 1, 3, 2, 2, 1, 3, 2, 0, 1,
@ -496,7 +496,7 @@ static unsigned LZ4_NbCommonBytes (reg_t val)
_BitScanReverse64( &r, val ); _BitScanReverse64( &r, val );
return (unsigned)(r>>3); return (unsigned)(r>>3);
# elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT) # elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT)
return (__builtin_clzll((U64)val) >> 3); return (unsigned)__builtin_clzll((U64)val) >> 3;
# else # else
static const U32 by32 = sizeof(val)*4; /* 32 on 64 bits (goal), 16 on 32 bits. static const U32 by32 = sizeof(val)*4; /* 32 on 64 bits (goal), 16 on 32 bits.
Just to avoid some static analyzer complaining about shift by 32 on 32-bits target. Just to avoid some static analyzer complaining about shift by 32 on 32-bits target.
@ -513,7 +513,7 @@ static unsigned LZ4_NbCommonBytes (reg_t val)
_BitScanReverse( &r, (unsigned long)val ); _BitScanReverse( &r, (unsigned long)val );
return (unsigned)(r>>3); return (unsigned)(r>>3);
# elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT) # elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT)
return (__builtin_clz((U32)val) >> 3); return (unsigned)__builtin_clz((U32)val) >> 3;
# else # else
unsigned r; unsigned r;
if (!(val>>16)) { r=2; val>>=8; } else { r=0; val>>=24; } if (!(val>>16)) { r=2; val>>=8; } else { r=0; val>>=24; }

View File

@ -1015,10 +1015,10 @@ static void FUZ_unitTests(int compressionLevel)
/* in-place compression test */ /* in-place compression test */
DISPLAYLEVEL(3, "in-place compression using LZ4_compress_default() :"); DISPLAYLEVEL(3, "in-place compression using LZ4_compress_default() :");
{ size_t const sampleSize = 65 KB; { int const sampleSize = 65 KB;
size_t const maxCSize = LZ4_COMPRESSBOUND(sampleSize); int const maxCSize = LZ4_COMPRESSBOUND(sampleSize);
size_t const outSize = LZ4_COMPRESS_INPLACE_BUFFER_SIZE(maxCSize); int const outSize = LZ4_COMPRESS_INPLACE_BUFFER_SIZE(maxCSize);
size_t const startIndex = outSize - sampleSize; int const startIndex = outSize - sampleSize;
char* const startInput = testCompressed + startIndex; char* const startInput = testCompressed + startIndex;
XXH32_hash_t const crcOrig = XXH32(testInput, sampleSize, 0); XXH32_hash_t const crcOrig = XXH32(testInput, sampleSize, 0);
int cSize; int cSize;
@ -1028,7 +1028,7 @@ static void FUZ_unitTests(int compressionLevel)
cSize = LZ4_compress_default(startInput, testCompressed, sampleSize, maxCSize); cSize = LZ4_compress_default(startInput, testCompressed, sampleSize, maxCSize);
assert(cSize != 0); /* ensure compression is successful */ assert(cSize != 0); /* ensure compression is successful */
assert(maxCSize < INT_MAX); assert(maxCSize < INT_MAX);
assert(cSize <= (int)maxCSize); assert(cSize <= maxCSize);
/* decompress and verify */ /* decompress and verify */
{ int const dSize = LZ4_decompress_safe(testCompressed, testVerify, cSize, testInputSize); { int const dSize = LZ4_decompress_safe(testCompressed, testVerify, cSize, testInputSize);
assert(dSize == (int)sampleSize); /* correct size */ assert(dSize == (int)sampleSize); /* correct size */