git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC/PATCHv2] Makefile: add cppcheck target

From
Chris Packham <judge.packham@gmail.com>
Date
Dec 14, 2016, 09:27 UTC
Message-ID
<20161214092731.29076-1-judge.packham@gmail.com>
In-Reply-To
<20161213092225.15299-1-judge.packham@gmail.com>

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@gmail.com>
Signed-off-by: Chris Packham <judge.packham@gmail.com>
---
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
Previous: Jeff KingNext: Jeff King
Message 9 of 15 in “Makefile: add cppcheck target”
  1. Makefile: add cppcheck targetChris Packham, Dec 13, 2016
  2. Chris PackhamDec 13, 2016
  3. stefan.naewe@atlas-elektronik.comDec 13, 2016
  4. Jeff KingDec 13, 2016
  5. Jeff KingDec 13, 2016
  6. Chris PackhamDec 14, 2016
  7. Chris PackhamDec 14, 2016
  8. Jeff KingDec 14, 2016
  9. [RFC/PATCHv2] Makefile: add cppcheck targetChris Packham, Dec 14, 2016
  10. Jeff KingDec 14, 2016
  11. Jeff KingDec 14, 2016
  12. Makefile: suppress some cppcheck false-positivesChris Packham, Dec 15, 2016
  13. Junio C HamanoDec 16, 2016
  14. Jeff KingDec 16, 2016
  15. Chris PackhamDec 17, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.