Modified : Makefile : added -Wshadow option, suggest by Boris Faure
authorYann Collet <yann.collet.73@gmail.com>
Sat, 5 Jul 2014 12:33:57 +0000 (13:33 +0100)
committerYann Collet <yann.collet.73@gmail.com>
Sat, 5 Jul 2014 12:33:57 +0000 (13:33 +0100)
Makefile
lz4.c
programs/Makefile
programs/lz4io.c

index b8c259c..9b8dbe6 100644 (file)
--- 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 (file)
--- 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
                 {
index 3d7aadf..c62366c 100644 (file)
@@ -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
 # 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
index 49caed3..65d1445 100644 (file)
@@ -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;