From e002818cf6aba7e2f56a08b8d9306b026f90ec4e Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Sat, 5 Jul 2014 13:33:57 +0100 Subject: [PATCH] Modified : Makefile : added -Wshadow option, suggest by Boris Faure --- Makefile | 2 +- lz4.c | 6 +++--- programs/Makefile | 8 ++++---- programs/lz4io.c | 15 +++++++-------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index b8c259c..9b8dbe6 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ LIBVER=$(LIBVER_MAJOR).$(LIBVER_MINOR).$(LIBVER_PATCH) DESTDIR= PREFIX = /usr CC := $(CC) -CFLAGS+= -I. -std=c99 -O3 -Wall -W -Wundef -DLZ4_VERSION=\"$(RELEASE)\" +CFLAGS+= -I. -std=c99 -O3 -Wall -Wextra -Wundef -Wshadow -DLZ4_VERSION=\"$(RELEASE)\" LIBDIR?= $(PREFIX)/lib INCLUDEDIR=$(PREFIX)/include diff --git a/lz4.c b/lz4.c index 482a8ed..1a864e9 100644 --- a/lz4.c +++ b/lz4.c @@ -986,9 +986,9 @@ FORCE_INLINE int LZ4_decompress_generic( copySize = length+MINMATCH - copySize; if (copySize > (size_t)((char*)op-dest)) /* overlap */ { - BYTE* const cpy = op + copySize; - const BYTE* ref = (BYTE*)dest; - while (op < cpy) *op++ = *ref++; + BYTE* const endOfMatch = op + copySize; + const BYTE* copyFrom = (BYTE*)dest; + while (op < endOfMatch) *op++ = *copyFrom++; } else { diff --git a/programs/Makefile b/programs/Makefile index 3d7aadf..c62366c 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -1,4 +1,4 @@ -# ################################################################ +# ########################################################################## # LZ4 programs - Makefile # Copyright (C) Yann Collet 2011-2014 # GPL v2 License @@ -20,7 +20,7 @@ # You can contact the author at : # - LZ4 source repository : http://code.google.com/p/lz4/ # - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c -# ################################################################ +# ########################################################################## # lz4 : Command Line Utility, supporting gzip-like arguments # lz4c : CLU, supporting also legacy lz4demo arguments # lz4c32: Same as lz4c, but forced to compile in 32-bits mode @@ -28,13 +28,13 @@ # fuzzer32: Same as fuzzer, but forced to compile in 32-bits mode # fullbench : Precisely measure speed for each LZ4 function variant # fullbench32: Same as fullbench, but forced to compile in 32-bits mode -# ################################################################ +# ########################################################################## RELEASE=rc120 DESTDIR= PREFIX=/usr CC:=$(CC) -CFLAGS+= -std=c99 -O3 -Wall -W -Wundef -DLZ4_VERSION=\"$(RELEASE)\" +CFLAGS+= -std=c99 -O3 -Wall -Wextra -Wundef -Wshadow -DLZ4_VERSION=\"$(RELEASE)\" FLAGS= -I.. $(CFLAGS) BINDIR=$(PREFIX)/bin diff --git a/programs/lz4io.c b/programs/lz4io.c index 49caed3..65d1445 100644 --- a/programs/lz4io.c +++ b/programs/lz4io.c @@ -149,7 +149,7 @@ static const int one = 1; //************************************** static int displayLevel = 0; // 0 : no display // 1: errors // 2 : + result + interaction + warnings ; // 3 : + progression; // 4 : + information static int overwrite = 1; -static int blockSizeId = LZ4S_BLOCKSIZEID_DEFAULT; +static int globalBlockSizeId = LZ4S_BLOCKSIZEID_DEFAULT; static int blockChecksum = 0; static int streamChecksum = 1; static int blockIndependence = 1; @@ -198,8 +198,8 @@ int LZ4IO_setBlockSizeID(int bsid) { static const int blockSizeTable[] = { 64 KB, 256 KB, 1 MB, 4 MB }; if ((bsid < minBlockSizeID) || (bsid > maxBlockSizeID)) return -1; - blockSizeId = bsid; - return blockSizeTable[blockSizeId-minBlockSizeID]; + globalBlockSizeId = bsid; + return blockSizeTable[globalBlockSizeId-minBlockSizeID]; } @@ -303,7 +303,6 @@ int LZ4IO_compressFilename_Legacy(char* input_filename, char* output_filename, i char* out_buff; FILE* finput; FILE* foutput; - int displayLevel = (compressionlevel>0); clock_t start, end; size_t sizeCheck; @@ -424,7 +423,7 @@ static int compress_file_blockDependency(char* input_filename, char* output_file } get_fileHandle(input_filename, output_filename, &finput, &foutput); - blockSize = LZ4S_GetBlockSize_FromBlockId (blockSizeId); + blockSize = LZ4S_GetBlockSize_FromBlockId (globalBlockSizeId); // Allocate Memory inputBufferSize = 64 KB + blockSize; @@ -442,7 +441,7 @@ static int compress_file_blockDependency(char* input_filename, char* output_file *(out_buff+4) |= (blockIndependence & _1BIT) << 5; *(out_buff+4) |= (blockChecksum & _1BIT) << 4; *(out_buff+4) |= (streamChecksum & _1BIT) << 2; - *(out_buff+5) = (char)((blockSizeId & _3BITS) << 4); + *(out_buff+5) = (char)((globalBlockSizeId & _3BITS) << 4); checkbits = XXH32((out_buff+4), 2, LZ4S_CHECKSUM_SEED); checkbits = LZ4S_GetCheckBits_FromXXH(checkbits); *(out_buff+6) = (unsigned char) checkbits; @@ -570,7 +569,7 @@ int LZ4IO_compressFilename(char* input_filename, char* output_filename, int comp if (compressionLevel <= 3) compressionFunction = LZ4_compress_limitedOutput_local; else { compressionFunction = LZ4_compressHC2_limitedOutput; } get_fileHandle(input_filename, output_filename, &finput, &foutput); - blockSize = LZ4S_GetBlockSize_FromBlockId (blockSizeId); + blockSize = LZ4S_GetBlockSize_FromBlockId (globalBlockSizeId); // Allocate Memory in_buff = (char*)malloc(blockSize); @@ -585,7 +584,7 @@ int LZ4IO_compressFilename(char* input_filename, char* output_filename, int comp *(headerBuffer+4) |= (blockIndependence & _1BIT) << 5; *(headerBuffer+4) |= (blockChecksum & _1BIT) << 4; *(headerBuffer+4) |= (streamChecksum & _1BIT) << 2; - *(headerBuffer+5) = (char)((blockSizeId & _3BITS) << 4); + *(headerBuffer+5) = (char)((globalBlockSizeId & _3BITS) << 4); checkbits = XXH32((headerBuffer+4), 2, LZ4S_CHECKSUM_SEED); checkbits = LZ4S_GetCheckBits_FromXXH(checkbits); *(headerBuffer+6) = (unsigned char) checkbits; -- 2.7.4