From 5a10ed2f7bb6fc9bffbabb2035ff1515e21bf25c Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 18 Sep 2018 16:52:02 -0700 Subject: [PATCH] added cppcheck as Makefile target and Travis CI test. Fixed last cppcheck warnings in tests and examples --- .travis.yml | 3 ++- Makefile | 5 +++++ contrib/gen_manual/gen_manual.cpp | 4 ++-- tests/frametest.c | 4 ++-- 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 diff --git a/Makefile b/Makefile index e8e6473..2f8b85c 100644 --- a/Makefile +++ b/Makefile @@ -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