From 923cf4447fdb5c5a007ff06279d79506e75bad6b Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 14 Nov 2016 18:09:31 -0800 Subject: [PATCH 1/9] bump version number --- NEWS | 2 +- lib/lz4.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 054265c..9bb1a62 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -v1.7.2 +v1.7.3 Changed : moved to versioning; package, cli and library have same version number Improved: Small decompression speed boost Improved: Small compression speed improvement on 64-bits systems diff --git a/lib/lz4.h b/lib/lz4.h index c1ea91a..babd78c 100644 --- a/lib/lz4.h +++ b/lib/lz4.h @@ -85,7 +85,7 @@ extern "C" { /*========== Version =========== */ #define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */ #define LZ4_VERSION_MINOR 7 /* for new (non-breaking) interface capabilities */ -#define LZ4_VERSION_RELEASE 2 /* for tweaks, bug-fixes, or development */ +#define LZ4_VERSION_RELEASE 3 /* for tweaks, bug-fixes, or development */ #define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE) From 0d6dc079f8b5948994fc0db953aae5e586a5e7de Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 15 Nov 2016 11:27:37 -0800 Subject: [PATCH 2/9] update appveyor tokens --- appveyor.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 37f3bd5..210f5d7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -34,9 +34,9 @@ install: ) build_script: - - if [%PLATFORM%]==[mingw32] SET PATH=%PATH_MINGW32%;%PATH_ORIGINAL% - - if [%PLATFORM%]==[mingw64] SET PATH=%PATH_MINGW64%;%PATH_ORIGINAL% - - if [%PLATFORM%]==[clang] SET PATH=%PATH_MINGW64%;%PATH_ORIGINAL% + - if [%PLATFORM%]==[mingw32] SET PATH=%PATH_MINGW32%;%PATH_ORIGINAL% + - if [%PLATFORM%]==[mingw64] SET PATH=%PATH_MINGW64%;%PATH_ORIGINAL% + - if [%PLATFORM%]==[clang] SET PATH=%PATH_MINGW64%;%PATH_ORIGINAL% - ECHO *** && ECHO Building %COMPILER% %PLATFORM% %CONFIGURATION% && ECHO *** @@ -108,11 +108,11 @@ test_script: - if not [%COMPILER%]==[unknown] ( CD programs && lz4 -h && - lz4 -i1b lz4.exe && + lz4 -i1b lz4.exe && lz4 -i1b5 lz4.exe && lz4 -i1b10 lz4.exe && lz4 -i1b15 lz4.exe && - echo ------- lz4 tested ------- && + echo ------- lz4 tested ------- && fullbench.exe -i1 fullbench.exe ) @@ -125,7 +125,7 @@ artifacts: deploy: - provider: GitHub auth_token: - secure: LgJo8emYc3sFnlNWkGl4/VYK3nk/8+RagcsqDlAi3xeqNGNutnKjcftjg84uJoT4 + secure: w6UJaGie0qbZvffr/fqyhO/Vj8rMiQWnv9a8qm3gxfngdHDTMT42wYupqJpIExId artifact: bin\lz4.exe force_update: true on: @@ -135,7 +135,7 @@ deploy: - provider: GitHub auth_token: - secure: LgJo8emYc3sFnlNWkGl4/VYK3nk/8+RagcsqDlAi3xeqNGNutnKjcftjg84uJoT4 + secure: w6UJaGie0qbZvffr/fqyhO/Vj8rMiQWnv9a8qm3gxfngdHDTMT42wYupqJpIExId artifact: bin\lz4_32.exe force_update: true on: @@ -145,7 +145,7 @@ deploy: - provider: GitHub auth_token: - secure: LgJo8emYc3sFnlNWkGl4/VYK3nk/8+RagcsqDlAi3xeqNGNutnKjcftjg84uJoT4 + secure: w6UJaGie0qbZvffr/fqyhO/Vj8rMiQWnv9a8qm3gxfngdHDTMT42wYupqJpIExId artifact: bin\liblz4_x64.zip force_update: true on: @@ -155,7 +155,7 @@ deploy: - provider: GitHub auth_token: - secure: LgJo8emYc3sFnlNWkGl4/VYK3nk/8+RagcsqDlAi3xeqNGNutnKjcftjg84uJoT4 + secure: w6UJaGie0qbZvffr/fqyhO/Vj8rMiQWnv9a8qm3gxfngdHDTMT42wYupqJpIExId artifact: bin\liblz4_x86.zip force_update: true on: From 2906c373c8aae65c938662ef12b56bcae3b457b0 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 15 Nov 2016 12:58:53 -0800 Subject: [PATCH 3/9] fixed appveyor badges --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b0033f2..91661a9 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,9 @@ LZ4 library is provided as open-source software using BSD 2-Clause license. [travisMasterBadge]: https://travis-ci.org/lz4/lz4.svg?branch=master "Continuous Integration test suite" [travisDevBadge]: https://travis-ci.org/lz4/lz4.svg?branch=dev "Continuous Integration test suite" [travisLink]: https://travis-ci.org/lz4/lz4 -[AppveyorMasterBadge]: https://ci.appveyor.com/api/projects/status/v6kxv9si529477cq/branch/master?svg=true "Visual test suite" -[AppveyorDevBadge]: https://ci.appveyor.com/api/projects/status/v6kxv9si529477cq/branch/dev?svg=true "Visual test suite" -[AppveyorLink]: https://ci.appveyor.com/project/YannCollet/lz4 +[AppveyorMasterBadge]: https://ci.appveyor.com/api/projects/status/jc2yhgwyc7qqtsko/branch/master?svg=true "Windows test suite" +[AppveyorDevBadge]: https://ci.appveyor.com/api/projects/status/jc2yhgwyc7qqtsko/branch/dev?svg=true "Windows test suite" +[AppveyorLink]: https://ci.appveyor.com/project/YannCollet/lz4-1lndh [coverBadge]: https://scan.coverity.com/projects/4735/badge.svg "Static code analysis of Master branch" [coverlink]: https://scan.coverity.com/projects/4735 From 2eddc8ea2cb5c8b35ab1beef7672031fe4fa5abe Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 15 Nov 2016 13:01:23 -0800 Subject: [PATCH 4/9] removed .travis.yml, for better rebase --- .travis.yml | 127 ---------------------------------------------------- 1 file changed, 127 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f4facad..0000000 --- a/.travis.yml +++ /dev/null @@ -1,127 +0,0 @@ -language: c -matrix: - fast_finish: true - include: - # OS X Mavericks - - os: osx - env: Ubu=OS_X_Mavericks Cmd='make -C tests test-lz4 CC=clang MOREFLAGS="-Werror -Wconversion -Wno-sign-conversion"' COMPILER=clang - - # Container-based 12.04 LTS Server Edition 64 bit (doesn't support 32-bit includes) - - os: linux - sudo: false - env: Ubu=12.04cont Cmd='make -C tests test-lz4 test-lz4c test-fasttest test-fullbench' COMPILER=cc - - - os: linux - sudo: false - env: Ubu=12.04cont Cmd='make -C tests test-frametest test-fuzzer' COMPILER=cc - - - os: linux - sudo: false - env: Ubu=12.04cont Cmd="make gpptest-native && make clean && make examples && make clean && make cmake && make clean && make travis-install && make clean && make clangtest-native" COMPILER=cc - - - # 14.04 LTS Server Edition 64 bit - - env: Ubu=14.04 Cmd='make -C tests test-lz4c32 test-fullbench32 versionsTest' COMPILER=cc - dist: trusty - sudo: required - addons: - apt: - packages: - - python3 - - libc6-dev-i386 - - gcc-multilib - - - env: Ubu=14.04 Cmd='make -C tests test-frametest32 test-fuzzer32' COMPILER=cc - dist: trusty - sudo: required - addons: - apt: - packages: - - libc6-dev-i386 - - gcc-multilib - - - env: Ubu=14.04 Cmd='make sanitize' COMPILER=clang - dist: trusty - sudo: required - addons: - apt: - packages: - - valgrind - - - env: Ubu=14.04 Cmd='make staticAnalyze' COMPILER=clang - dist: trusty - sudo: required - addons: - apt: - packages: - - clang - - - env: Ubu=14.04 Cmd='make platformTest CC=arm-linux-gnueabi-gcc QEMU_SYS=qemu-arm-static && make platformTest CC=aarch64-linux-gnu-gcc QEMU_SYS=qemu-aarch64-static' COMPILER=arm-linux-gnueabi-gcc - dist: trusty - sudo: required - addons: - apt: - packages: - - qemu-system-arm - - qemu-user-static - - gcc-arm-linux-gnueabi - - libc6-dev-armel-cross - - gcc-aarch64-linux-gnu - - libc6-dev-arm64-cross - - - env: Ubu=14.04 Cmd='make platformTest CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc-static && make platformTest CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc64-static MOREFLAGS=-m64' COMPILER=powerpc-linux-gnu-gcc - dist: trusty - sudo: required - addons: - apt: - packages: - - qemu-system-ppc - - qemu-user-static - - gcc-powerpc-linux-gnu - - - env: Ubu=14.04 Cmd='make c_standards && make -C tests test-lz4 test-mem' COMPILER=cc - dist: trusty - sudo: required - addons: - apt: - packages: - - valgrind - - - env: Ubu=14.04 Cmd='make -C tests test-lz4 test-lz4c32 CC=gcc-5 MOREFLAGS=-Werror' COMPILER=gcc-5 - dist: trusty - sudo: required - addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - libc6-dev-i386 - - gcc-multilib - - gcc-5 - - gcc-5-multilib - - - env: Ubu=14.04 Cmd='make c_standards CC=gcc-6 && make -C tests test-lz4 CC=gcc-6 MOREFLAGS=-Werror' COMPILER=gcc-6 - dist: trusty - sudo: required - addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - gcc-6 - - - env: Ubu=14.04 Cmd='make -C tests test-lz4 CC=clang-3.8' COMPILER=clang-3.8 - dist: trusty - sudo: required - addons: - apt: - sources: - - ubuntu-toolchain-r-test - - llvm-toolchain-precise-3.8 - packages: - - clang-3.8 - -script: - - echo Cmd=$Cmd - - $COMPILER -v - - sh -c "$Cmd" From 8c32a12f1c50a5561a9efcfe802b5109379a4120 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 15 Nov 2016 13:01:50 -0800 Subject: [PATCH 5/9] .travis.yml for coverity --- .travis.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..a9d7049 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,25 @@ +language: c +compiler: gcc +script: make all +before_install: + - sudo apt-get update -qq + - sudo apt-get install -qq gcc-multilib + +env: + global: + # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created + # via the "travis encrypt" command using the project repo's public key + - secure: "dTX2Mzka5xLZa0Dy46j+adFGV2e9IXyZtU2+HXlO3a/i1PA3Y4Kt6NSFgCfB3i7jdy+arxyqPOXVH72sHsHiaiMNYFL2d3mQ6XYjOQ4KIE/WW/hZijHtrV9OYJZoJZTuOSRTv+dMuypWJ9XXVxTy4xnUIGQxLa/Fw0LNtjTIt2w=" + +addons: + coverity_scan: + project: + name: "Cyan4973/lz4" + description: "Build submitted via Travis CI" + notification_email: yann.collet.73@gmail.com + build_command_prepend: "make clean" + build_command: "make all" + branch_pattern: coverity_scan + +matrix: + fast_finish: true From d2be69b144d6c5fd9a3dcbc4133e93e710cda998 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 15 Nov 2016 14:01:37 -0800 Subject: [PATCH 6/9] fixed minor coverity warnings --- lib/lz4frame.c | 37 ++++++++++++++++++------------------- programs/bench.c | 1 + programs/datagen.c | 27 +++++++++------------------ programs/lz4.1 | 3 ++- programs/lz4cli.c | 22 ++++++++-------------- programs/lz4io.c | 7 ++++--- programs/lz4io.h | 16 ++++++++++------ 7 files changed, 52 insertions(+), 61 deletions(-) diff --git a/lib/lz4frame.c b/lib/lz4frame.c index c31f82d..c8e5bde 100644 --- a/lib/lz4frame.c +++ b/lib/lz4frame.c @@ -817,9 +817,8 @@ static size_t LZ4F_headerSize(const void* src, size_t srcSize) */ static size_t LZ4F_decodeHeader(LZ4F_dctx* dctxPtr, const void* src, size_t srcSize) { - BYTE FLG, BD, HC; + BYTE FLG, BD; unsigned version, blockMode, blockChecksumFlag, contentSizeFlag, contentChecksumFlag, blockSizeID; - size_t bufferNeeded; size_t frameHeaderSize; const BYTE* srcPtr = (const BYTE*)src; @@ -877,9 +876,9 @@ static size_t LZ4F_decodeHeader(LZ4F_dctx* dctxPtr, const void* src, size_t srcS if (blockSizeID < 4) return err0r(LZ4F_ERROR_maxBlockSize_invalid); /* 4-7 only supported values for the time being */ if (((BD>>0)&_4BITS) != 0) return err0r(LZ4F_ERROR_reservedFlag_set); /* Reserved bits */ - /* check */ - HC = LZ4F_headerChecksum(srcPtr+4, frameHeaderSize-5); - if (HC != srcPtr[frameHeaderSize-1]) return err0r(LZ4F_ERROR_headerChecksum_invalid); /* Bad header checksum error */ + /* check header */ + { BYTE const HC = LZ4F_headerChecksum(srcPtr+4, frameHeaderSize-5); + if (HC != srcPtr[frameHeaderSize-1]) return err0r(LZ4F_ERROR_headerChecksum_invalid); } /* save */ dctxPtr->frameInfo.blockMode = (LZ4F_blockMode_t)blockMode; @@ -892,17 +891,17 @@ static size_t LZ4F_decodeHeader(LZ4F_dctx* dctxPtr, const void* src, size_t srcS /* init */ if (contentChecksumFlag) XXH32_reset(&(dctxPtr->xxh), 0); - /* alloc */ - bufferNeeded = dctxPtr->maxBlockSize + ((dctxPtr->frameInfo.blockMode==LZ4F_blockLinked) * 128 KB); - if (bufferNeeded > dctxPtr->maxBufferSize) { /* tmp buffers too small */ - FREEMEM(dctxPtr->tmpIn); - FREEMEM(dctxPtr->tmpOutBuffer); - dctxPtr->maxBufferSize = bufferNeeded; - dctxPtr->tmpIn = (BYTE*)ALLOCATOR(dctxPtr->maxBlockSize); - if (dctxPtr->tmpIn == NULL) return err0r(LZ4F_ERROR_GENERIC); - dctxPtr->tmpOutBuffer= (BYTE*)ALLOCATOR(dctxPtr->maxBufferSize); - if (dctxPtr->tmpOutBuffer== NULL) return err0r(LZ4F_ERROR_GENERIC); - } + /* internal buffers allocation */ + { size_t const bufferNeeded = dctxPtr->maxBlockSize + ((dctxPtr->frameInfo.blockMode==LZ4F_blockLinked) * 128 KB); + if (bufferNeeded > dctxPtr->maxBufferSize) { /* tmp buffers too small */ + FREEMEM(dctxPtr->tmpIn); + dctxPtr->tmpIn = (BYTE*)ALLOCATOR(dctxPtr->maxBlockSize); + if (dctxPtr->tmpIn == NULL) return err0r(LZ4F_ERROR_allocation_failed); + dctxPtr->maxBufferSize = bufferNeeded; + FREEMEM(dctxPtr->tmpOutBuffer); + dctxPtr->tmpOutBuffer= (BYTE*)ALLOCATOR(bufferNeeded); + if (dctxPtr->tmpOutBuffer== NULL) return err0r(LZ4F_ERROR_allocation_failed); + } } dctxPtr->tmpInSize = 0; dctxPtr->tmpInTarget = 0; dctxPtr->dict = dctxPtr->tmpOutBuffer; @@ -981,9 +980,9 @@ static void LZ4F_updateDict(LZ4F_dctx* dctxPtr, const BYTE* dstPtr, size_t dstSi } if (withinTmp) { /* copy relevant dict portion in front of tmpOut within tmpOutBuffer */ - size_t preserveSize = dctxPtr->tmpOut - dctxPtr->tmpOutBuffer; + size_t const preserveSize = dctxPtr->tmpOut - dctxPtr->tmpOutBuffer; size_t copySize = 64 KB - dctxPtr->tmpOutSize; - const BYTE* oldDictEnd = dctxPtr->dict + dctxPtr->dictSize - dctxPtr->tmpOutStart; + const BYTE* const oldDictEnd = dctxPtr->dict + dctxPtr->dictSize - dctxPtr->tmpOutStart; if (dctxPtr->tmpOutSize > 64 KB) copySize = 0; if (copySize > preserveSize) copySize = preserveSize; @@ -996,7 +995,7 @@ static void LZ4F_updateDict(LZ4F_dctx* dctxPtr, const BYTE* dstPtr, size_t dstSi if (dctxPtr->dict == dctxPtr->tmpOutBuffer) { /* copy dst into tmp to complete dict */ if (dctxPtr->dictSize + dstSize > dctxPtr->maxBufferSize) { /* tmp buffer not large enough */ - size_t preserveSize = 64 KB - dstSize; /* note : dstSize < 64 KB */ + size_t const preserveSize = 64 KB - dstSize; /* note : dstSize < 64 KB */ memcpy(dctxPtr->tmpOutBuffer, dctxPtr->dict + dctxPtr->dictSize - preserveSize, preserveSize); dctxPtr->dictSize = preserveSize; } diff --git a/programs/bench.c b/programs/bench.c index cfd60db..434da8b 100644 --- a/programs/bench.c +++ b/programs/bench.c @@ -260,6 +260,7 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize, cSize = 0; { U32 blockNb; for (blockNb=0; blockNb%10u (%5.3f),%6.1f MB/s\r", diff --git a/programs/datagen.c b/programs/datagen.c index d851418..ed37c2a 100644 --- a/programs/datagen.c +++ b/programs/datagen.c @@ -81,10 +81,10 @@ typedef BYTE litDistribTable[LTSIZE]; - /********************************************************* * Local Functions *********************************************************/ +#define MIN(a,b) ( (a) < (b) ? (a) :(b) ) #define RDG_rotl32(x,r) ((x << r) | (x >> (32 - r))) static unsigned int RDG_rand(U32* src) { @@ -99,24 +99,15 @@ static unsigned int RDG_rand(U32* src) static void RDG_fillLiteralDistrib(litDistribTable lt, double ld) { - U32 i = 0; - BYTE character = '0'; - BYTE firstChar = '('; - BYTE lastChar = '}'; + BYTE const firstChar = ld <= 0.0 ? 0 : '('; + BYTE const lastChar = ld <= 0.0 ? 255 : '}'; + BYTE character = ld <= 0.0 ? 0 : '0'; + U32 u = 0; - if (ld==0.0) - { - character = 0; - firstChar = 0; - lastChar =255; - } - while (i LTSIZE) weight = LTSIZE-i; - end = i + weight; - while (i < end) lt[i++] = character; + while (u lastChar) character = firstChar; } diff --git a/programs/lz4.1 b/programs/lz4.1 index 434b131..2c94033 100644 --- a/programs/lz4.1 +++ b/programs/lz4.1 @@ -207,7 +207,8 @@ hence for a file. It won't work with unknown source size, such as stdin or pipe. sparse mode support (default:enabled on file, disabled on stdout) .TP .B \-l - use Legacy format (useful for Linux Kernel compression) + use Legacy format (typically used for Linux Kernel compression) + note : \fB-l\fR is not compatible with \fB-m\fR (\fB--multiple\fR) . .SS "Other options" .TP diff --git a/programs/lz4cli.c b/programs/lz4cli.c index 88fbb53..e9a0d4b 100644 --- a/programs/lz4cli.c +++ b/programs/lz4cli.c @@ -288,11 +288,11 @@ int main(int argc, const char** argv) const char* input_filename = NULL; const char* output_filename= NULL; char* dynNameSpace = NULL; - const char** inFileNames = NULL; + const char** inFileNames = (const char**) calloc(argc, sizeof(char*));; unsigned ifnIdx=0; const char nullOutput[] = NULL_OUTPUT; const char extension[] = LZ4_EXTENSION; - int blockSize = LZ4IO_setBlockSizeID(LZ4_BLOCKSIZEID_DEFAULT); + size_t blockSize = LZ4IO_setBlockSizeID(LZ4_BLOCKSIZEID_DEFAULT); const char* const exeName = argv[0]; #ifdef UTIL_HAS_CREATEFILELIST const char** extendedFileList = NULL; @@ -301,6 +301,10 @@ int main(int argc, const char** argv) #endif /* Init */ + if (inFileNames==NULL) { + DISPLAY("Allocation error : not enough memory \n"); + return 1; + } LZ4IO_setOverwrite(0); /* lz4cat predefined behavior */ @@ -311,8 +315,6 @@ int main(int argc, const char** argv) output_filename=stdoutmark; displayLevel=1; multiple_inputs=1; - inFileNames = (const char**) calloc(argc, sizeof(char*)); - if (inFileNames==NULL) { perror(exeName); exit(1); } } if (!strcmp(exeName, UNLZ4)) { mode = om_decompress; } @@ -336,7 +338,7 @@ int main(int argc, const char** argv) if (!strcmp(argument, "--compress")) { mode = om_compress; continue; } if ((!strcmp(argument, "--decompress")) || (!strcmp(argument, "--uncompress"))) { mode = om_decompress; continue; } - if (!strcmp(argument, "--multiple")) { multiple_inputs = 1; if (inFileNames==NULL) inFileNames = (const char**)malloc(argc * sizeof(char*)); continue; } + if (!strcmp(argument, "--multiple")) { multiple_inputs = 1; continue; } if (!strcmp(argument, "--test")) { mode = om_test; continue; } if (!strcmp(argument, "--force")) { LZ4IO_setOverwrite(1); continue; } if (!strcmp(argument, "--no-force")) { LZ4IO_setOverwrite(0); continue; } @@ -454,10 +456,6 @@ int main(int argc, const char** argv) /* Benchmark */ case 'b': mode = om_bench; multiple_inputs=1; - if (inFileNames == NULL) { - inFileNames = (const char**) calloc(argc, sizeof(char*)); - if (inFileNames==NULL) { perror(exeName); exit(1); } - } break; #ifdef UTIL_HAS_CREATEFILELIST @@ -466,10 +464,6 @@ int main(int argc, const char** argv) #endif /* Treat non-option args as input files. See https://code.google.com/p/lz4/issues/detail?id=151 */ case 'm': multiple_inputs=1; - if (inFileNames == NULL) { - inFileNames = (const char**) calloc(argc, sizeof(char*)); - if (inFileNames==NULL) { perror(exeName); exit(1); } - } break; /* Modify Nb Seconds (benchmark only) */ @@ -514,7 +508,7 @@ int main(int argc, const char** argv) } DISPLAYLEVEL(3, WELCOME_MESSAGE); - if ((mode == om_compress) || (mode == om_bench)) DISPLAYLEVEL(4, "Blocks size : %i KB\n", blockSize>>10); + if ((mode == om_compress) || (mode == om_bench)) DISPLAYLEVEL(4, "Blocks size : %i KB\n", (U32)(blockSize>>10)); if (multiple_inputs) { input_filename = inFileNames[0]; diff --git a/programs/lz4io.c b/programs/lz4io.c index 5a366a4..f34d715 100644 --- a/programs/lz4io.c +++ b/programs/lz4io.c @@ -183,10 +183,10 @@ int LZ4IO_setTestMode(int yes) } /* blockSizeID : valid values : 4-5-6-7 */ -int LZ4IO_setBlockSizeID(int bsid) +size_t LZ4IO_setBlockSizeID(unsigned bsid) { - static const int blockSizeTable[] = { 64 KB, 256 KB, 1 MB, 4 MB }; - if ((bsid < minBlockSizeID) || (bsid > maxBlockSizeID)) return -1; + static const size_t blockSizeTable[] = { 64 KB, 256 KB, 1 MB, 4 MB }; + if ((bsid < minBlockSizeID) || (bsid > maxBlockSizeID)) return 0; g_blockSizeId = bsid; return blockSizeTable[g_blockSizeId-minBlockSizeID]; } @@ -777,6 +777,7 @@ static dRess_t LZ4IO_createDResources(void) ress.dstBuffer = malloc(ress.dstBufferSize); if (!ress.srcBuffer || !ress.dstBuffer) EXM_THROW(61, "Allocation error : not enough memory"); + ress.dstFile = NULL; return ress; } diff --git a/programs/lz4io.h b/programs/lz4io.h index 315c805..e1ab5f3 100644 --- a/programs/lz4io.h +++ b/programs/lz4io.h @@ -32,16 +32,20 @@ #ifndef LZ4IO_H_237902873 #define LZ4IO_H_237902873 +/*--- Dependency ---*/ +#include /* size_t */ + + /* ************************************************** */ /* Special input/output values */ /* ************************************************** */ #define NULL_OUTPUT "null" -static char const stdinmark[] = "stdin"; -static char const stdoutmark[] = "stdout"; +static const char stdinmark[] = "stdin"; +static const char stdoutmark[] = "stdout"; #ifdef _WIN32 -static char const nulmark[] = "nul"; +static const char nulmark[] = "nul"; #else -static char const nulmark[] = "/dev/null"; +static const char nulmark[] = "/dev/null"; #endif @@ -69,8 +73,8 @@ int LZ4IO_setOverwrite(int yes); int LZ4IO_setTestMode(int yes); /* blockSizeID : valid values : 4-5-6-7 - return : -1 if error, blockSize if OK */ -int LZ4IO_setBlockSizeID(int blockSizeID); + return : 0 if error, blockSize if OK */ +size_t LZ4IO_setBlockSizeID(unsigned blockSizeID); /* Default setting : independent blocks */ typedef enum { LZ4IO_blockLinked=0, LZ4IO_blockIndependent} LZ4IO_blockMode_t; From d613e24945a8cca8aa8985c111f02797d289200c Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 15 Nov 2016 14:49:21 -0800 Subject: [PATCH 7/9] restored .travis.yml --- .travis.yml | 146 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 124 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index a9d7049..f4facad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,127 @@ language: c -compiler: gcc -script: make all -before_install: - - sudo apt-get update -qq - - sudo apt-get install -qq gcc-multilib - -env: - global: - # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created - # via the "travis encrypt" command using the project repo's public key - - secure: "dTX2Mzka5xLZa0Dy46j+adFGV2e9IXyZtU2+HXlO3a/i1PA3Y4Kt6NSFgCfB3i7jdy+arxyqPOXVH72sHsHiaiMNYFL2d3mQ6XYjOQ4KIE/WW/hZijHtrV9OYJZoJZTuOSRTv+dMuypWJ9XXVxTy4xnUIGQxLa/Fw0LNtjTIt2w=" - -addons: - coverity_scan: - project: - name: "Cyan4973/lz4" - description: "Build submitted via Travis CI" - notification_email: yann.collet.73@gmail.com - build_command_prepend: "make clean" - build_command: "make all" - branch_pattern: coverity_scan - matrix: fast_finish: true + include: + # OS X Mavericks + - os: osx + env: Ubu=OS_X_Mavericks Cmd='make -C tests test-lz4 CC=clang MOREFLAGS="-Werror -Wconversion -Wno-sign-conversion"' COMPILER=clang + + # Container-based 12.04 LTS Server Edition 64 bit (doesn't support 32-bit includes) + - os: linux + sudo: false + env: Ubu=12.04cont Cmd='make -C tests test-lz4 test-lz4c test-fasttest test-fullbench' COMPILER=cc + + - os: linux + sudo: false + env: Ubu=12.04cont Cmd='make -C tests test-frametest test-fuzzer' COMPILER=cc + + - os: linux + sudo: false + env: Ubu=12.04cont Cmd="make gpptest-native && make clean && make examples && make clean && make cmake && make clean && make travis-install && make clean && make clangtest-native" COMPILER=cc + + + # 14.04 LTS Server Edition 64 bit + - env: Ubu=14.04 Cmd='make -C tests test-lz4c32 test-fullbench32 versionsTest' COMPILER=cc + dist: trusty + sudo: required + addons: + apt: + packages: + - python3 + - libc6-dev-i386 + - gcc-multilib + + - env: Ubu=14.04 Cmd='make -C tests test-frametest32 test-fuzzer32' COMPILER=cc + dist: trusty + sudo: required + addons: + apt: + packages: + - libc6-dev-i386 + - gcc-multilib + + - env: Ubu=14.04 Cmd='make sanitize' COMPILER=clang + dist: trusty + sudo: required + addons: + apt: + packages: + - valgrind + + - env: Ubu=14.04 Cmd='make staticAnalyze' COMPILER=clang + dist: trusty + sudo: required + addons: + apt: + packages: + - clang + + - env: Ubu=14.04 Cmd='make platformTest CC=arm-linux-gnueabi-gcc QEMU_SYS=qemu-arm-static && make platformTest CC=aarch64-linux-gnu-gcc QEMU_SYS=qemu-aarch64-static' COMPILER=arm-linux-gnueabi-gcc + dist: trusty + sudo: required + addons: + apt: + packages: + - qemu-system-arm + - qemu-user-static + - gcc-arm-linux-gnueabi + - libc6-dev-armel-cross + - gcc-aarch64-linux-gnu + - libc6-dev-arm64-cross + + - env: Ubu=14.04 Cmd='make platformTest CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc-static && make platformTest CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc64-static MOREFLAGS=-m64' COMPILER=powerpc-linux-gnu-gcc + dist: trusty + sudo: required + addons: + apt: + packages: + - qemu-system-ppc + - qemu-user-static + - gcc-powerpc-linux-gnu + + - env: Ubu=14.04 Cmd='make c_standards && make -C tests test-lz4 test-mem' COMPILER=cc + dist: trusty + sudo: required + addons: + apt: + packages: + - valgrind + + - env: Ubu=14.04 Cmd='make -C tests test-lz4 test-lz4c32 CC=gcc-5 MOREFLAGS=-Werror' COMPILER=gcc-5 + dist: trusty + sudo: required + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - libc6-dev-i386 + - gcc-multilib + - gcc-5 + - gcc-5-multilib + + - env: Ubu=14.04 Cmd='make c_standards CC=gcc-6 && make -C tests test-lz4 CC=gcc-6 MOREFLAGS=-Werror' COMPILER=gcc-6 + dist: trusty + sudo: required + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-6 + + - env: Ubu=14.04 Cmd='make -C tests test-lz4 CC=clang-3.8' COMPILER=clang-3.8 + dist: trusty + sudo: required + addons: + apt: + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.8 + packages: + - clang-3.8 + +script: + - echo Cmd=$Cmd + - $COMPILER -v + - sh -c "$Cmd" From 929badd611544f28ed887c380f55e282a101e6bd Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 15 Nov 2016 14:57:12 -0800 Subject: [PATCH 8/9] fixed sign conversion warning --- programs/lz4io.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/programs/lz4io.c b/programs/lz4io.c index f34d715..4d076a9 100644 --- a/programs/lz4io.c +++ b/programs/lz4io.c @@ -134,9 +134,6 @@ static int g_blockIndependence = 1; static int g_sparseFileSupport = 1; static int g_contentSizeFlag = 0; -static const int minBlockSizeID = 4; -static const int maxBlockSizeID = 7; - /************************************** * Exceptions @@ -186,6 +183,8 @@ int LZ4IO_setTestMode(int yes) size_t LZ4IO_setBlockSizeID(unsigned bsid) { static const size_t blockSizeTable[] = { 64 KB, 256 KB, 1 MB, 4 MB }; + static const unsigned minBlockSizeID = 4; + static const unsigned maxBlockSizeID = 7; if ((bsid < minBlockSizeID) || (bsid > maxBlockSizeID)) return 0; g_blockSizeId = bsid; return blockSizeTable[g_blockSizeId-minBlockSizeID]; From 00fa1b9c018cf7dc80a07a1192555469577c675c Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 15 Nov 2016 15:06:56 -0800 Subject: [PATCH 9/9] fixed double ;; for Visual --- programs/lz4cli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/lz4cli.c b/programs/lz4cli.c index e9a0d4b..297ce6b 100644 --- a/programs/lz4cli.c +++ b/programs/lz4cli.c @@ -288,7 +288,7 @@ int main(int argc, const char** argv) const char* input_filename = NULL; const char* output_filename= NULL; char* dynNameSpace = NULL; - const char** inFileNames = (const char**) calloc(argc, sizeof(char*));; + const char** inFileNames = (const char**) calloc(argc, sizeof(char*)); unsigned ifnIdx=0; const char nullOutput[] = NULL_OUTPUT; const char extension[] = LZ4_EXTENSION;