From a1d7b9d654279cbea2a8a27a88b5e43894cf47a1 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Wed, 3 Mar 2021 15:17:12 -0800 Subject: [PATCH] fixed gcc conversion warnings --- .../seekable_format/tests/seekable_tests.c | 56 +++++++++---------- contrib/seekable_format/zstdseek_compress.c | 11 ++-- 2 files changed, 33 insertions(+), 34 deletions(-) diff --git a/contrib/seekable_format/tests/seekable_tests.c b/contrib/seekable_format/tests/seekable_tests.c index af851dd63..7a276bc4c 100644 --- a/contrib/seekable_format/tests/seekable_tests.c +++ b/contrib/seekable_format/tests/seekable_tests.c @@ -60,34 +60,34 @@ int main(int argc, const char** argv) { /* Github issue #FIXME */ const size_t compressed_size = 27; const uint8_t compressed_data[27] = { - '\x28', - '\xb5', - '\x2f', - '\xfd', - '\x00', - '\x32', - '\x91', - '\x00', - '\x00', - '\x00', - '\x5e', - '\x2a', - '\x4d', - '\x18', - '\x09', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\xb1', - '\xea', - '\x92', - '\x8f', - }; + (uint8_t)'\x28', + (uint8_t)'\xb5', + (uint8_t)'\x2f', + (uint8_t)'\xfd', + (uint8_t)'\x00', + (uint8_t)'\x32', + (uint8_t)'\x91', + (uint8_t)'\x00', + (uint8_t)'\x00', + (uint8_t)'\x00', + (uint8_t)'\x5e', + (uint8_t)'\x2a', + (uint8_t)'\x4d', + (uint8_t)'\x18', + (uint8_t)'\x09', + (uint8_t)'\x00', + (uint8_t)'\x00', + (uint8_t)'\x00', + (uint8_t)'\x00', + (uint8_t)'\x00', + (uint8_t)'\x00', + (uint8_t)'\x00', + (uint8_t)'\x00', + (uint8_t)'\xb1', + (uint8_t)'\xea', + (uint8_t)'\x92', + (uint8_t)'\x8f', + }; const size_t uncompressed_size = 400; uint8_t uncompressed_data[400]; diff --git a/contrib/seekable_format/zstdseek_compress.c b/contrib/seekable_format/zstdseek_compress.c index f153aee73..442f9bee9 100644 --- a/contrib/seekable_format/zstdseek_compress.c +++ b/contrib/seekable_format/zstdseek_compress.c @@ -202,7 +202,7 @@ size_t ZSTD_seekable_endFrame(ZSTD_seekable_CStream* zcs, ZSTD_outBuffer* output /* end the frame */ size_t ret = ZSTD_endStream(zcs->cstream, output); - zcs->frameCSize += output->pos - prevOutPos; + zcs->frameCSize += (U32)(output->pos - prevOutPos); /* need to flush before doing the rest */ if (ret) return ret; @@ -245,8 +245,8 @@ size_t ZSTD_seekable_compressStream(ZSTD_seekable_CStream* zcs, ZSTD_outBuffer* XXH64_update(&zcs->xxhState, inBase, inTmp.pos); } - zcs->frameCSize += output->pos - prevOutPos; - zcs->frameDSize += inTmp.pos; + zcs->frameCSize += (U32)(output->pos - prevOutPos); + zcs->frameDSize += (U32)inTmp.pos; input->pos += inTmp.pos; @@ -287,7 +287,7 @@ static inline size_t ZSTD_stwrite32(ZSTD_frameLog* fl, memcpy((BYTE*)output->dst + output->pos, tmp + (fl->seekTablePos - offset), lenWrite); output->pos += lenWrite; - fl->seekTablePos += lenWrite; + fl->seekTablePos += (U32)lenWrite; if (lenWrite < 4) return ZSTD_seekable_seekTableSize(fl) - fl->seekTablePos; } @@ -336,8 +336,7 @@ size_t ZSTD_seekable_writeSeekTable(ZSTD_frameLog* fl, ZSTD_outBuffer* output) if (output->size - output->pos < 1) return seekTableLen - fl->seekTablePos; if (fl->seekTablePos < seekTableLen - 4) { - BYTE sfd = 0; - sfd |= (fl->checksumFlag) << 7; + BYTE const sfd = (BYTE)((fl->checksumFlag) << 7); ((BYTE*)output->dst)[output->pos] = sfd; output->pos++;