Static Analysis Devconf15
Static Analysis Devconf15
Red Hat
Kamil Dudka
February 6th, 2015
Abstract
This demo session will show how we can easily check the sanity
of code in our project. There is a tool named csmock, which
takes a source RPM (or upstream tarball) and produces a list
of possible defects in its code. Besides plug-ins for C/C++
analyzers (Clang, Cppcheck, and GCC), csmock now comes
with experimental plug-ins for static analysis of python and
shell scripts. We will also discuss how we can efficiently
process the results of these tools and how to integrate them
into our workflow.
Static Analysis
1 / 20
Agenda
2 / 20
Running Static Analyzers
Install csmock:
sudo yum install csmock
sudo gpasswd -a $USER mock
3 / 20
Running Static Analyzers
4 / 20
Running Static Analyzers
5 / 20
Running Static Analyzers
6 / 20
Running Static Analyzers
7 / 20
Running Static Analyzers
8 / 20
Running Static Analyzers
Error: CPPCHECK_WARNING:
lib/llist.c:113: error[assignBoolToPointer]: Boolean value assigned to pointer.
Error: COMPILER_WARNING:
lib/llist.c: scope_hint: In function "Curl_llist_remove"
lib/llist.c:113:8: warning: assignment makes pointer from integer without a cast
# if(e = NULL || list->size == 0)
# ^
Error: CLANG_WARNING:
lib/llist.c:117:18: warning: Access to field "next" results in a dereference
of a null pointer (loaded from variable "e")
...
9 / 20
Running Static Analyzers
10 / 20
Running Static Analyzers
11 / 20
Running Static Analyzers
break something
12 / 20
Running Static Analyzers
13 / 20
Running Static Analyzers
14 / 20
Agenda
csdiff warnings-{old,new}.txt
csdiff warnings-{old,new}.txt --fixed
csdiff warnings-{old,new}.txt --ignore-path
15 / 20
Processing the Results of Static Analyzers
16 / 20
Processing the Results of Static Analyzers
17 / 20
Processing the Results of Static Analyzers
18 / 20
Processing the Results of Static Analyzers
Future Plans
19 / 20
Processing the Results of Static Analyzers
Conclusion
20 / 20