Add cppcheck target to Makefile. Cppcheck is a static analysis tool for C/C++ code. Cppcheck primarily detects the types of bugs that the compilers normally do not detect. It is an useful target for doing QA analysis. To run the default set of checks run make cppcheck Additional checks can be enabled by specifying CPPCHECK_ADD. This is a comma separated list which is passed to cppcheck's --enable option. To enable style and warning checks run make cppcheck CPPCHECK_ADD=style,warning Based-on-patch-by: Elia Pinto <gitter.spiros@xxxxxxxxx> Signed-off-by: Chris Packham <judge.packham@xxxxxxxxx> --- Changes in v2: - only run over actual git source files. - omit any files in t/ - print cppcheck version to allow for better comparison between different build environments - introduce CPPCHECK_FLAGS which can be overridden in the make command line. This also uses a GNU make-ism to allow CPPCHECK_ADD to specify additional checks to be enabled. Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index f53fcc90d..e5c86decf 100644 --- a/Makefile +++ b/Makefile @@ -2635,3 +2635,12 @@ cover_db: coverage-report cover_db_html: cover_db cover -report html -outputdir cover_db_html cover_db +.PHONY: cppcheck + +CPPCHECK_FLAGS = --force --quiet --inline-suppr $(if $(CPPCHECK_ADD),--enable=$(CPPCHECK_ADD)) + +cppcheck: + @cppcheck --version + $(FIND_SOURCE_FILES) | \ + grep -v '^t/t' | \ + xargs cppcheck $(CPPCHECK_FLAGS) -- 2.11.0.24.ge6920cf