From 1b24cc115595f7cd2f8f5f6de0a9d44a70bdf827 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 14 Nov 2016 07:10:31 -0800 Subject: [PATCH 1/7] fixed conversion warnings --- Makefile | 5 ++++- lib/lz4.h | 8 ++++---- tests/frametest.c | 26 ++++++++++++-------------- tests/fuzzer.c | 16 ++++++++-------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index e92ae8d..3f1b414 100644 --- a/Makefile +++ b/Makefile @@ -91,9 +91,12 @@ travis-install: test: $(MAKE) -C $(TESTDIR) test +clangtest: CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" clangtest: clean clang -v - CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) all CC=clang + @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(LZ4DIR) all CC=clang + @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(PRGDIR) all CC=clang + @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(TESTDIR) all CC=clang sanitize: clean CFLAGS="-O3 -g -fsanitize=undefined" $(MAKE) test CC=clang FUZZER_TIME="-T1mn" NB_LOOPS=-i1 diff --git a/lib/lz4.h b/lib/lz4.h index 17abd52..d5ac9cb 100644 --- a/lib/lz4.h +++ b/lib/lz4.h @@ -1,7 +1,7 @@ /* - LZ4 - Fast LZ compression algorithm - Header File - Copyright (C) 2011-2016, Yann Collet. + * LZ4 - Fast LZ compression algorithm + * Header File + * Copyright (C) 2011-2016, Yann Collet. BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) @@ -423,7 +423,7 @@ struct LZ4_streamDecode_s { # elif defined(_MSC_VER) # define LZ4_DEPRECATED(message) __declspec(deprecated(message)) # else -# warning "WARNING: You need to implement LZ4_DEPRECATED for this compiler" +# pragma message("WARNING: You need to implement LZ4_DEPRECATED for this compiler") # define LZ4_DEPRECATED(message) # endif #endif /* LZ4_DISABLE_DEPRECATE_WARNINGS */ diff --git a/tests/frametest.c b/tests/frametest.c index d4afc58..a99728f 100644 --- a/tests/frametest.c +++ b/tests/frametest.c @@ -139,10 +139,10 @@ unsigned int FUZ_rand(unsigned int* src) #define FUZ_RAND15BITS (FUZ_rand(seed) & 0x7FFF) #define FUZ_RANDLENGTH ( (FUZ_rand(seed) & 3) ? (FUZ_rand(seed) % 15) : (FUZ_rand(seed) % 510) + 15) -static void FUZ_fillCompressibleNoiseBuffer(void* buffer, unsigned bufferSize, double proba, U32* seed) +static void FUZ_fillCompressibleNoiseBuffer(void* buffer, size_t bufferSize, double proba, U32* seed) { BYTE* BBuffer = (BYTE*)buffer; - unsigned pos = 0; + size_t pos = 0; U32 P32 = (U32)(32768 * proba); /* First Byte */ @@ -152,20 +152,18 @@ static void FUZ_fillCompressibleNoiseBuffer(void* buffer, unsigned bufferSize, d /* Select : Literal (noise) or copy (within 64K) */ if (FUZ_RAND15BITS < P32) { /* Copy (within 64K) */ - unsigned match, end; - unsigned length = FUZ_RANDLENGTH + 4; - unsigned offset = FUZ_RAND15BITS + 1; - if (offset > pos) offset = pos; - if (pos + length > bufferSize) length = bufferSize - pos; - match = pos - offset; - end = pos + length; + size_t const lengthRand = FUZ_RANDLENGTH + 4; + size_t const length = MIN(lengthRand, bufferSize - pos); + size_t const end = pos + length; + size_t const offsetRand = FUZ_RAND15BITS + 1; + size_t const offset = MIN(offsetRand, pos); + size_t match = pos - offset; while (pos < end) BBuffer[pos++] = BBuffer[match++]; } else { /* Literal (noise) */ - unsigned end; - unsigned length = FUZ_RANDLENGTH; - if (pos + length > bufferSize) length = bufferSize - pos; - end = pos + length; + size_t const lengthRand = FUZ_RANDLENGTH + 4; + size_t const length = MIN(lengthRand, bufferSize - pos); + size_t const end = pos + length; while (pos < end) BBuffer[pos++] = (BYTE)(FUZ_rand(seed) >> 5); } } @@ -606,7 +604,7 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi /* main fuzzer test loop */ for ( ; (testNb < nbTests) || (clockDuration > FUZ_GetClockSpan(startClock)) ; testNb++) { U32 randState = coreRand ^ prime1; - unsigned const srcBits = (FUZ_rand(&randState) % (FUZ_highbit(srcDataLength-1) - 1)) + 1; + unsigned const srcBits = (FUZ_rand(&randState) % (FUZ_highbit((U32)(srcDataLength-1)) - 1)) + 1; size_t const srcSize = (FUZ_rand(&randState) & ((1< Date: Mon, 14 Nov 2016 08:51:28 -0800 Subject: [PATCH 2/7] clang and g++ tests restricted to native only on Travis CI Ubuntu v12 environment --- .travis.yml | 32 ++++++++++++++++---------------- Makefile | 22 ++++++++++++++++++---- lib/Makefile | 4 ++-- programs/Makefile | 10 ++++++---- tests/Makefile | 9 +++++---- 5 files changed, 47 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4bef528..f4facad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,21 +5,21 @@ matrix: # 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 && make clean && make examples && make clean && make cmake && make clean && make travis-install && make clean && make clangtest" COMPILER=cc - - + 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 @@ -30,7 +30,7 @@ matrix: - python3 - libc6-dev-i386 - gcc-multilib - + - env: Ubu=14.04 Cmd='make -C tests test-frametest32 test-fuzzer32' COMPILER=cc dist: trusty sudo: required @@ -39,7 +39,7 @@ matrix: packages: - libc6-dev-i386 - gcc-multilib - + - env: Ubu=14.04 Cmd='make sanitize' COMPILER=clang dist: trusty sudo: required @@ -47,7 +47,7 @@ matrix: apt: packages: - valgrind - + - env: Ubu=14.04 Cmd='make staticAnalyze' COMPILER=clang dist: trusty sudo: required @@ -55,7 +55,7 @@ matrix: 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 @@ -65,10 +65,10 @@ matrix: - qemu-system-arm - qemu-user-static - gcc-arm-linux-gnueabi - - libc6-dev-armel-cross + - 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 @@ -78,7 +78,7 @@ matrix: - 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 @@ -86,7 +86,7 @@ matrix: 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 @@ -99,7 +99,7 @@ matrix: - 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 @@ -109,7 +109,7 @@ matrix: - 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 diff --git a/Makefile b/Makefile index 3f1b414..c6454b0 100644 --- a/Makefile +++ b/Makefile @@ -91,13 +91,18 @@ travis-install: test: $(MAKE) -C $(TESTDIR) test -clangtest: CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" clangtest: clean clang -v @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(LZ4DIR) all CC=clang @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(PRGDIR) all CC=clang @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(TESTDIR) all CC=clang +clangtest-native: clean + clang -v + @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(LZ4DIR) all CC=clang + @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(PRGDIR) native CC=clang + @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(TESTDIR) native CC=clang + sanitize: clean CFLAGS="-O3 -g -fsanitize=undefined" $(MAKE) test CC=clang FUZZER_TIME="-T1mn" NB_LOOPS=-i1 @@ -108,8 +113,8 @@ platformTest: clean @echo "\n ---- test lz4 with $(CC) compiler ----" @$(CC) -v CFLAGS="-O3 -Werror" $(MAKE) -C $(LZ4DIR) all - CFLAGS="-O3 -Werror -static" $(MAKE) -C $(PRGDIR) bins - CFLAGS="-O3 -Werror -static" $(MAKE) -C $(TESTDIR) bins + CFLAGS="-O3 -Werror -static" $(MAKE) -C $(PRGDIR) native + CFLAGS="-O3 -Werror -static" $(MAKE) -C $(TESTDIR) native $(MAKE) -C $(TESTDIR) test-platform versionsTest: clean @@ -138,7 +143,16 @@ cmake: @cd contrib/cmake_unofficial; cmake $(CMAKE_PARAMS) CMakeLists.txt; $(MAKE) gpptest: clean - CC=g++ $(MAKE) all CFLAGS="-O3 -I../lib -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror" + g++ -v + CC=g++ $(MAKE) -C $(LZ4DIR) all CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror" + CC=g++ $(MAKE) -C $(PRGDIR) all CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror" + CC=g++ $(MAKE) -C $(TESTDIR) all CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror" + +gpptest-native: clean + g++ -v + CC=g++ $(MAKE) -C $(LZ4DIR) all CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror" + CC=g++ $(MAKE) -C $(PRGDIR) native CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror" + CC=g++ $(MAKE) -C $(TESTDIR) native CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror" c_standards: clean $(MAKE) all MOREFLAGS="-std=gnu90 -Werror" diff --git a/lib/Makefile b/lib/Makefile index 6551dd9..d098846 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -48,7 +48,7 @@ CPPFLAGS= -DXXH_NAMESPACE=LZ4_ CFLAGS ?= -O3 CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \ -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef \ - -Wpointer-arith # -Wstrict-aliasing=1 + -Wpointer-arith -Wstrict-aliasing=1 CFLAGS += $(MOREFLAGS) FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) @@ -85,7 +85,7 @@ endif liblz4: *.c @echo compiling dynamic library $(LIBVER) -ifneq (,$(filter Windows%,$(OS))) +ifneq (,$(filter Windows%,$(OS))) @$(CC) $(FLAGS) -DLZ4_DLL_EXPORT=1 -shared $^ -o $@.dll dlltool -D liblz4.dll -d liblz4.def -l liblz4.dll.a else diff --git a/programs/Makefile b/programs/Makefile index 5c2bdcd..de18f78 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -34,8 +34,10 @@ BINDIR := $(PREFIX)/bin MANDIR := $(PREFIX)/share/man/man1 LZ4DIR := ../lib -CFLAGS ?= -O3 # can select custom flags. For example : CFLAGS="-O2 -g" make -CFLAGS += -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wpointer-arith +CFLAGS ?= -O3 # allows custom optimization flags. For example : CFLAGS="-O2 -g" make +CFLAGS += -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow \ + -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes \ + -Wpointer-arith -Wstrict-aliasing=1 CFLAGS += $(MOREFLAGS) CPPFLAGS:= -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_ FLAGS := $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) @@ -54,9 +56,9 @@ default: lz4 m32: lz4c32 -bins: lz4 lz4c +native: lz4 lz4c -all: bins m32 +all: native m32 lz4: $(LZ4DIR)/lz4.o $(LZ4DIR)/lz4hc.o $(LZ4DIR)/lz4frame.o $(LZ4DIR)/xxhash.o bench.o lz4io.o lz4cli.o datagen.o $(CC) $(FLAGS) $^ -o $@$(EXT) diff --git a/tests/Makefile b/tests/Makefile index 4481392..a0ddc7c 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -42,7 +42,8 @@ TESTDIR := versionsTest PYTHON ?= python3 CFLAGS ?= -O3 # can select custom flags. For example : CFLAGS="-O2 -g" make -CFLAGS += -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes +CFLAGS += -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow -Wswitch-enum \ + -Wdeclaration-after-statement -Wstrict-prototypes CFLAGS += $(MOREFLAGS) CPPFLAGS:= -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_ FLAGS := $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) @@ -62,13 +63,13 @@ FUZZER_TIME := -T3mn NB_LOOPS ?= -i1 -default: bins +default: native m32: fullbench32 fuzzer32 frametest32 -bins: fullbench fuzzer frametest datagen fasttest +native: fullbench fuzzer frametest datagen fasttest -all: bins m32 +all: native m32 lz4: From fa158b4118f2d53f6e84ce6ce16aa8d3ccd8a11a Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 14 Nov 2016 10:02:01 -0800 Subject: [PATCH 3/7] fixed nameless union warnings --- lib/lz4.h | 12 ++++-------- lib/lz4hc.h | 6 ++---- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/lz4.h b/lib/lz4.h index d5ac9cb..c1ea91a 100644 --- a/lib/lz4.h +++ b/lib/lz4.h @@ -226,7 +226,7 @@ LZ4LIB_API int LZ4_decompress_safe_partial (const char* source, char* dest, int /*-********************************************* * Streaming Compression Functions ***********************************************/ -typedef struct LZ4_stream_s LZ4_stream_t; /* incomplete type (defined later) */ +typedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */ /*! LZ4_createStream() and LZ4_freeStream() : * LZ4_createStream() will allocate and initialize an `LZ4_stream_t` structure. @@ -272,7 +272,7 @@ LZ4LIB_API int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int dict * Streaming Decompression Functions * Bufferless synchronous API ************************************************/ -typedef struct LZ4_streamDecode_s LZ4_streamDecode_t; /* incomplete type (defined later) */ +typedef union LZ4_streamDecode_u LZ4_streamDecode_t; /* incomplete type (defined later) */ /* creation / destruction of streaming decompression tracking structure */ LZ4LIB_API LZ4_streamDecode_t* LZ4_createStreamDecode(void); @@ -378,11 +378,9 @@ typedef struct { */ #define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE-3)) + 4) #define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U64 * sizeof(unsigned long long)) -struct LZ4_stream_s { - union { +union LZ4_stream_u { unsigned long long table[LZ4_STREAMSIZE_U64]; LZ4_stream_t_internal internal_donotuse; - }; } ; /* previously typedef'd to LZ4_stream_t */ @@ -396,11 +394,9 @@ struct LZ4_stream_s { */ #define LZ4_STREAMDECODESIZE_U64 4 #define LZ4_STREAMDECODESIZE (LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long)) -struct LZ4_streamDecode_s { - union { +union LZ4_streamDecode_u { unsigned long long table[LZ4_STREAMDECODESIZE_U64]; LZ4_streamDecode_t_internal internal_donotuse; - }; } ; /* previously typedef'd to LZ4_streamDecode_t */ diff --git a/lib/lz4hc.h b/lib/lz4hc.h index 7adc8fa..d8ac3c0 100644 --- a/lib/lz4hc.h +++ b/lib/lz4hc.h @@ -83,7 +83,7 @@ LZ4LIB_API int LZ4_sizeofStateHC(void); * Streaming Compression * Bufferless synchronous API **************************************/ - typedef struct LZ4_streamHC_s LZ4_streamHC_t; /* incomplete type (defined later) */ + typedef union LZ4_streamHC_u LZ4_streamHC_t; /* incomplete type (defined later) */ /*! LZ4_createStreamHC() and LZ4_freeStreamHC() : * These functions create and release memory for LZ4 HC streaming state. @@ -176,11 +176,9 @@ typedef struct #define LZ4_STREAMHCSIZE 262192 #define LZ4_STREAMHCSIZE_SIZET (LZ4_STREAMHCSIZE / sizeof(size_t)) -struct LZ4_streamHC_s { - union { +union LZ4_streamHC_u { size_t table[LZ4_STREAMHCSIZE_SIZET]; LZ4HC_CCtx_internal internal_donotuse; - }; }; /* previously typedef'd to LZ4_streamHC_t */ /* LZ4_streamHC_t : From 201149f8eb456c499014e772cdbd298045afbec3 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 14 Nov 2016 10:16:11 -0800 Subject: [PATCH 4/7] fixed conversion warnings --- tests/Makefile | 3 ++- tests/fuzzer.c | 20 ++------------------ 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index a0ddc7c..a11cf9b 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -43,7 +43,8 @@ PYTHON ?= python3 CFLAGS ?= -O3 # can select custom flags. For example : CFLAGS="-O2 -g" make CFLAGS += -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow -Wswitch-enum \ - -Wdeclaration-after-statement -Wstrict-prototypes + -Wdeclaration-after-statement -Wstrict-prototypes \ + -Wpointer-arith -Wstrict-aliasing=1 CFLAGS += $(MOREFLAGS) CPPFLAGS:= -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_ FLAGS := $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) diff --git a/tests/fuzzer.c b/tests/fuzzer.c index 50f6871..301b01a 100644 --- a/tests/fuzzer.c +++ b/tests/fuzzer.c @@ -300,24 +300,8 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c } /* move to startCycle */ - for (cycleNb = 0; cycleNb < startCycle; cycleNb++) { - U32 randState = FUZ_rand(&coreRandState) ^ PRIME3; - - if (0) { /* some problems can be related to dictionary re-use; in this case, enable this loop */ - int const blockSize = FUZ_rand(&randState) % FUZ_MAX_BLOCK_SIZE; - int const blockStart = FUZ_rand(&randState) % (COMPRESSIBLE_NOISE_LENGTH - blockSize); - int const dictSizeRand = FUZ_rand(&randState) % FUZ_MAX_DICT_SIZE; - int const dictSize = MIN(dictSizeRand, blockStart); - char* const block = ((char*)CNBuffer) + blockStart; - const char* const dict = block - dictSize; - FUZ_displayUpdate(cycleNb); - LZ4_loadDict(&LZ4dict, dict, dictSize); - LZ4_compress_fast_continue(&LZ4dict, block, compressedBuffer, blockSize, compressedBufferSize, 1); - LZ4_loadDict(&LZ4dict, dict, dictSize); - LZ4_compress_fast_continue(&LZ4dict, block, compressedBuffer, blockSize, compressedBufferSize, 1); - LZ4_loadDict(&LZ4dict, dict, dictSize); - LZ4_compress_fast_continue(&LZ4dict, block, compressedBuffer, blockSize, compressedBufferSize, 1); - } } + for (cycleNb = 0; cycleNb < startCycle; cycleNb++) + (void) FUZ_rand(&coreRandState); /* sync coreRandState */ /* Main test loop */ for (cycleNb = startCycle; From 0fe5c187a5fe95f5c129b1eda8d743b485fc6ff5 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 14 Nov 2016 11:34:10 -0800 Subject: [PATCH 5/7] fixed minor msan warning --- lib/lz4.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/lz4.c b/lib/lz4.c index 276c15a..e6b70bc 100644 --- a/lib/lz4.c +++ b/lib/lz4.c @@ -159,7 +159,7 @@ static unsigned LZ4_64bits(void) { return sizeof(void*)==8; } static unsigned LZ4_isLittleEndian(void) { - const union { U32 i; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */ + const union { U32 u; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */ return one.c[0]; } @@ -1113,7 +1113,7 @@ FORCE_INLINE int LZ4_decompress_generic( const BYTE* const lowLimit = lowPrefix - dictSize; const BYTE* const dictEnd = (const BYTE*)dictStart + dictSize; - const unsigned dec32table[] = {4, 1, 2, 1, 4, 4, 4, 4}; + const unsigned dec32table[] = {0, 1, 2, 1, 4, 4, 4, 4}; const int dec64table[] = {0, 0, 0, -1, 0, 1, 2, 3}; const int safeDecode = (endOnInput==endOnInputSize); From f094f531441140f10fd461ba769f49d10f5cd581 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 14 Nov 2016 14:38:46 -0800 Subject: [PATCH 6/7] silence a minor msan warning --- lib/lz4.c | 1 + programs/lz4io.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/lz4.c b/lib/lz4.c index e6b70bc..ff141be 100644 --- a/lib/lz4.c +++ b/lib/lz4.c @@ -1168,6 +1168,7 @@ FORCE_INLINE int LZ4_decompress_generic( offset = LZ4_readLE16(ip); ip+=2; match = op - offset; if ((checkOffset) && (unlikely(match < lowLimit))) goto _output_error; /* Error : offset outside buffers */ + LZ4_write32(op, offset); /* costs ~1%; silence an msan warning when offset==0 */ /* get matchlength */ length = token & ML_MASK; diff --git a/programs/lz4io.c b/programs/lz4io.c index 00576c2..5a366a4 100644 --- a/programs/lz4io.c +++ b/programs/lz4io.c @@ -824,7 +824,8 @@ static unsigned long long LZ4IO_decompressLZ4F(dRess_t ress, FILE* srcFile, FILE /* Write Block */ if (decodedBytes) { - if (!g_testMode) storedSkips = LZ4IO_fwriteSparse(dstFile, ress.dstBuffer, decodedBytes, storedSkips); + if (!g_testMode) + storedSkips = LZ4IO_fwriteSparse(dstFile, ress.dstBuffer, decodedBytes, storedSkips); filesize += decodedBytes; DISPLAYUPDATE(2, "\rDecompressed : %u MB ", (unsigned)(filesize>>20)); } From 4c5c711b7a7553def6b400df9efed5e8381e8e87 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 14 Nov 2016 14:53:15 -0800 Subject: [PATCH 7/7] fixed minor conversion warning --- lib/lz4.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/lz4.c b/lib/lz4.c index ff141be..89e3a0f 100644 --- a/lib/lz4.c +++ b/lib/lz4.c @@ -1127,13 +1127,12 @@ FORCE_INLINE int LZ4_decompress_generic( /* Main Loop : decode sequences */ while (1) { - unsigned token; size_t length; const BYTE* match; size_t offset; /* get literal length */ - token = *ip++; + unsigned const token = *ip++; if ((length=(token>>ML_BITS)) == RUN_MASK) { unsigned s; do { @@ -1168,7 +1167,7 @@ FORCE_INLINE int LZ4_decompress_generic( offset = LZ4_readLE16(ip); ip+=2; match = op - offset; if ((checkOffset) && (unlikely(match < lowLimit))) goto _output_error; /* Error : offset outside buffers */ - LZ4_write32(op, offset); /* costs ~1%; silence an msan warning when offset==0 */ + LZ4_write32(op, (U32)offset); /* costs ~1%; silence an msan warning when offset==0 */ /* get matchlength */ length = token & ML_MASK;