From bdde0cfa1d5848e59d20c1adc19ee1b687eec66a Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Thu, 4 Jun 2015 14:55:17 +0530 Subject: clang-analyzer: adding clang static analysis support clang static analyzer is a source code analysis tool that finds bugs in C, C++. This patch automates clang analyzes part by integrating it with 'make clang-check' clang-checker.sh: runs clang analyzer with and without the HEAD commit, and shows the bugs introduced by HEAD commit (if any) sample report: $[ glusterfs ]: make clang-check ================ Clang analyzer in progress ================ ... BASELINE BUGS LIST (before applying patch): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Out of bound array access --> 3 Memory leak --> 1 Unix API --> 24 Dead increment --> 5 Dereference of null pointer --> 1995 Uninitialized argument value --> 2 All Bugs --> 2872 Called function pointer is null null dereference --> 4 Dead initialization --> 49 Dead assignment --> 691 Undefined allocation of 0 bytes CERT MEM0 C CWE --> 5 Argument with nonnull attribute passed null --> 84 Result of operation is garbage or undefined --> 9 TARGET BUGS LIST (after applying patch): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Out of bound array access --> 3 Memory leak --> 1 Unix API --> 24 Dead increment --> 5 Dereference of null pointer --> 1995 Uninitialized argument value --> 2 All Bugs --> 2875 Called function pointer is null null dereference --> 4 Dead initialization --> 49 Dead assignment --> 694 Undefined allocation of 0 bytes CERT MEM0 C CWE --> 5 Argument with nonnull attribute passed null --> 84 Result of operation is garbage or undefined --> 9 SUMMARY OF CLANG-ANALYZER: ~~~~~~~~~~~~~~~~~~~~~~~~~~ Extra 3 Bug[s] Introduced in: Dead assignment Patch Value given by Clang analyzer '-1' Explore complete results at /home/user/work/glusterfs/baseline/results/index.html /home/user/work/glusterfs/target/results/index.html ================= Done with Clang Analysis ================= Change-Id: I512e33cfc02885a111152fbc1832144261dda1da BUG: 1228142 Signed-off-by: Prasanna Kumar Kalever Reviewed-on: http://review.gluster.org/11083 Tested-by: Prasanna Kumar Kalever NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Tested-by: Gluster Build System Smoke: Gluster Build System Reviewed-by: Raghavendra Talur Reviewed-by: Kaleb KEITHLEY --- Makefile.am | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Makefile.am') diff --git a/Makefile.am b/Makefile.am index d36f53055ea..180f149e328 100644 --- a/Makefile.am +++ b/Makefile.am @@ -47,7 +47,10 @@ dist-hook: gen-VERSION gen-ChangeLog -cp -f $(top_srcdir)/build-aux/config.sub.dist $(distdir)/config.sub -cp -f $(top_srcdir)/build-aux/config.guess.dist $(distdir)/config.guess -.PHONY: gen-VERSION gen-ChangeLog +.PHONY: gen-VERSION gen-ChangeLog clang-check + +clang-check: + @$(top_srcdir)/extras/clang-checker.sh gen-ChangeLog: (cd $(srcdir) && git diff && echo ===== git log ==== && git log) > $(distdir)/ChangeLog -- cgit