diff options
author | Yann Collet <cyan@fb.com> | 2018-09-18 23:52:02 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2018-09-18 23:52:02 (GMT) |
commit | 5a10ed2f7bb6fc9bffbabb2035ff1515e21bf25c (patch) | |
tree | 39084e05bdfd5f391d229b7ffff79ada08378d97 | |
parent | 697bd904b256e9927b65d23e187adb5dddf39399 (diff) | |
download | lz4-5a10ed2f7bb6fc9bffbabb2035ff1515e21bf25c.zip lz4-5a10ed2f7bb6fc9bffbabb2035ff1515e21bf25c.tar.gz lz4-5a10ed2f7bb6fc9bffbabb2035ff1515e21bf25c.tar.bz2 |
added cppcheck
as Makefile target and Travis CI test.
Fixed last cppcheck warnings in tests and examples
-rw-r--r-- | .travis.yml | 3 | ||||
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | contrib/gen_manual/gen_manual.cpp | 4 | ||||
-rw-r--r-- | tests/frametest.c | 4 | ||||
-rw-r--r-- | tests/fullbench.c | 4 |
5 files changed, 13 insertions, 7 deletions
diff --git a/.travis.yml b/.travis.yml index de6875b..5b0c6ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -129,13 +129,14 @@ matrix: - qemu-user-static - gcc-powerpc-linux-gnu - - env: Ubu=14.04 Cmd='make staticAnalyze' COMPILER=clang + - env: Ubu=14.04 Cmd='make staticAnalyze && make cppcheck' COMPILER=clang dist: trusty sudo: required addons: apt: packages: - clang + - cppcheck - env: Ubu=14.04 Cmd='make clean all CC=gcc-4.4 MOREFLAGS=-Werror && make clean && CFLAGS=-fPIC LDFLAGS="-pie -fPIE -D_FORTIFY_SOURCE=2" make -C programs' COMPILER=gcc-4.4 dist: trusty @@ -148,9 +148,14 @@ usan: clean usan32: clean CFLAGS="-m32 -O3 -g -fsanitize=undefined" $(MAKE) test FUZZER_TIME="-T30s" NB_LOOPS=-i1 +.PHONY: staticAnalyze staticAnalyze: clean CFLAGS=-g scan-build --status-bugs -v $(MAKE) all +.PHONY: cppcheck +cppcheck: + cppcheck . --force --enable=warning,portability,performance,style --error-exitcode=1 > /dev/null + platformTest: clean @echo "\n ---- test lz4 with $(CC) compiler ----" @$(CC) -v diff --git a/contrib/gen_manual/gen_manual.cpp b/contrib/gen_manual/gen_manual.cpp index e12273f..bedef94 100644 --- a/contrib/gen_manual/gen_manual.cpp +++ b/contrib/gen_manual/gen_manual.cpp @@ -180,9 +180,9 @@ int main(int argc, char *argv[]) { if (!comments.empty()) comments[comments.size()-1] = comments[comments.size()-1].substr(0, comments[comments.size()-1].find("*/")); for (l=0; l<comments.size(); l++) { - if (comments[l].find(" *") == 0) + if (comments[l].compare(0, 2, " *") == 0) comments[l] = comments[l].substr(2); - else if (comments[l].find(" *") == 0) + else if (comments[l].compare(0, 3, " *") == 0) comments[l] = comments[l].substr(3); trim(comments[l], "*-="); } diff --git a/tests/frametest.c b/tests/frametest.c index 4efeb6f..5714732 100644 --- a/tests/frametest.c +++ b/tests/frametest.c @@ -520,7 +520,7 @@ int basicTests(U32 seed, double compressibility) LZ4F_CDict* const cdict = LZ4F_createCDict(CNBuffer, dictSize); if (cdict == NULL) goto _output_error; CHECK( LZ4F_createCompressionContext(&cctx, LZ4F_VERSION) ); - + DISPLAYLEVEL(3, "LZ4F_compressFrame_usingCDict, with NULL dict : "); CHECK_V(cSizeNoDict, LZ4F_compressFrame_usingCDict(cctx, compressedBuffer, dstCapacity, @@ -840,7 +840,7 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi size_t const iSize = MIN(sampleMax, (size_t)(iend-ip)); size_t const oSize = LZ4F_compressBound(iSize, prefsPtr); cOptions.stableSrc = ((FUZ_rand(&randState) & 3) == 1); - DISPLAYLEVEL(6, "Sending %zi bytes to compress (stableSrc:%u) \n", + DISPLAYLEVEL(6, "Sending %zu bytes to compress (stableSrc:%u) \n", iSize, cOptions.stableSrc); result = LZ4F_compressUpdate(cCtx, op, oSize, ip, iSize, &cOptions); diff --git a/tests/fullbench.c b/tests/fullbench.c index fd1202d..4b4e921 100644 --- a/tests/fullbench.c +++ b/tests/fullbench.c @@ -367,7 +367,6 @@ int fullSpeedBench(const char** fileNamesTable, int nbFiles) size_t readSize; int compressedBuffSize; U32 crcOriginal; - size_t errorCode; /* Check file existence */ if (inFile==NULL) { DISPLAY( "Pb opening %s\n", inFileName); return 11; } @@ -561,7 +560,7 @@ int fullSpeedBench(const char** fileNamesTable, int nbFiles) case 8: decompressionFunction = local_LZ4_decompress_safe_forceExtDict; dName = "LZ4_decompress_safe_forceExtDict"; break; #endif case 9: decompressionFunction = local_LZ4F_decompress; dName = "LZ4F_decompress"; - errorCode = LZ4F_compressFrame(compressed_buff, compressedBuffSize, orig_buff, benchedSize, NULL); + { size_t const errorCode = LZ4F_compressFrame(compressed_buff, compressedBuffSize, orig_buff, benchedSize, NULL); if (LZ4F_isError(errorCode)) { DISPLAY("Error while preparing compressed frame\n"); free(orig_buff); @@ -573,6 +572,7 @@ int fullSpeedBench(const char** fileNamesTable, int nbFiles) chunkP[0].compressedSize = (int)errorCode; nbChunks = 1; break; + } default : continue; /* skip if unknown ID */ } |