From 35f7de52c8dc9c5d414eaae9c0300f0b5f875609 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Sun, 31 Jan 2016 02:51:03 +0100 Subject: [PATCH] fixed Visual warnings --- dictBuilder/dibcli.c | 9 +++++++++ dictBuilder/dictBuilder.c | 2 +- lib/zstd_compress.c | 4 ++-- lib/zstd_decompress.c | 3 +-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/dictBuilder/dibcli.c b/dictBuilder/dibcli.c index 3ca6854d..f93e9707 100644 --- a/dictBuilder/dibcli.c +++ b/dictBuilder/dibcli.c @@ -22,6 +22,15 @@ - zstd source repository : https://github.com/Cyan4973/zstd */ +/* ************************************** +* Compiler Specifics +****************************************/ +/* Disable some Visual warning messages */ +#ifdef _MSC_VER +# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ +#endif + + /*-************************************ * Includes **************************************/ diff --git a/dictBuilder/dictBuilder.c b/dictBuilder/dictBuilder.c index ca3f66f1..fed9b18d 100644 --- a/dictBuilder/dictBuilder.c +++ b/dictBuilder/dictBuilder.c @@ -79,7 +79,7 @@ #define DICTLISTSIZE 10000 #define MEMMULT 11 -static const size_t maxMemory = (sizeof(size_t)==4) ? (2 GB - 64 MB) : (size_t)(3 GB) * MEMMULT; +static const size_t maxMemory = (sizeof(size_t) == 4) ? (2 GB - 64 MB) : ((size_t)(512 MB) << sizeof(size_t)); #define NOISELENGTH 32 #define PRIME1 2654435761U diff --git a/lib/zstd_compress.c b/lib/zstd_compress.c index 37550e6b..6e3d6ca5 100644 --- a/lib/zstd_compress.c +++ b/lib/zstd_compress.c @@ -457,7 +457,7 @@ static size_t ZSTD_compressLiterals (ZSTD_CCtx* zc, U32 hType = IS_HUF; size_t clitSize; - if (maxDstSize < 4) return ERROR(dstSize_tooSmall); /* not enough space for compression */ + if (maxDstSize < lhSize+1) return ERROR(dstSize_tooSmall); /* not enough space for compression */ if (zc->flagStaticTables && (lhSize==3)) { hType = IS_PCH; @@ -547,7 +547,7 @@ size_t ZSTD_compressSequences(ZSTD_CCtx* zc, if ((oend-op) < MIN_SEQUENCES_SIZE) return ERROR(dstSize_tooSmall); if (nbSeq < 128) *op++ = (BYTE)nbSeq; else { - op[0] = (nbSeq>>8) + 128; op[1] = (BYTE)nbSeq; op+=2; + op[0] = (BYTE)((nbSeq>>8) + 128); op[1] = (BYTE)nbSeq; op+=2; } if (nbSeq==0) goto _check_compressibility; diff --git a/lib/zstd_decompress.c b/lib/zstd_decompress.c index 96ba8936..6061c874 100644 --- a/lib/zstd_decompress.c +++ b/lib/zstd_decompress.c @@ -812,8 +812,7 @@ static size_t ZSTD_decompressSequences( } /* check if reached exact end */ - if (nbSeq) - return ERROR(corruption_detected); /* DStream should be entirely and exactly consumed; otherwise data is corrupted */ + if (nbSeq) return ERROR(corruption_detected); } /* last literal segment */