Dave Jones: coverity, static checking etc.

May 22, 2014

Participants: Arnd Bergmann, Bjorn Helgaas, Dan Carpenter, Dmitry Torokhov, Guenter Roeck, Jiri Kosina, Johannes Berg, Josh Triplett, Mark Brown, Mauro Carvalho Chehab, Michal Simek, Peter Huewe, Roland Dreier, Ted Ts'o, and Wolfram Sang.

People tagged: Dan Carpenter, Christopher Li, and Fengguang Wu.

Dave Jones has been doing Coverity scans on the Linux kernel for more than a year, and would like to discuss the common trends and bug patterns that have been identified both via Coverity and using other tools such as smatch. Josh Triplett liked the topic, and put forward both gcc and the sparse tool as well. Johannes Berg liked the topic, but questioned the continued usefulness of sparse, given the large number of false positives. Guenter Roeck, Mark Brown, Jiri Kosina, Dmitry Torokhov, Josh Triplett, and Wolfram Sang all defended sparse's honor, accompanied by recommendations for coccicheck, cppcheck, smatch, and getting additional warnings into gcc.

Bjorn Helgaas expressed interest in the topic and in making the output of the various static-analysis tools more accessible and usable.

Arnd Bergmann asked about getting Coverity scan results for ARM, but

Dave replied that Coverity is currently an x86-only tool.

Arnd reported having built kernels for a given architecture, but generating code for some other architecture, purely for purposes of review. This entailed removing inline assembly and tweaking the compiler command line, and Arnd is apparently considering trying this with Coverity.

Roland Dreier likes easy-to run analysis tools because they allow people to contribute fixes for subtle bugs even when they don't have access to the corresponding hardware. Dave Jones expressed concern about giving out access to Coverity to too many people, especially to those having little or no track record of getting code into the kernel. Dave would like Coverity to add a feature to automatically route bug reports to the proper email list.

Ted Ts'o expressed interest and suggested that this might be more suited to a technical-talk track so as to reach a larger group of people. Dan Carpenter agreed, and offered to give a talk about smatch.

Wolfram Sang also suggested discussin workflows and experiences with the various tools. Michal Simek would like also like to see static checking on the kernel-doc comments, and would also like to see all these checkers be added to the kernel. Wolfram Sang noted the make C=1 facility already in the kernel that can be configured to invoke the checker of your choice, suggesting that it might even invoke multiple checkers at one go, perhaps even invoking all checkers installed on the system. Dan Carpenter said that smatch does not (yet) install well. Johannes Berg uses a simple script to invoke both sparse and smatch from make C=1. Guenter Roeck instead uses the CHECK= kmake argument to specify the checkers. Wolfram Sang uses his ninja-checker script to invoke all the static analyzers he knows of, and at Peter Huewe's request, posted the script here.

Mauro Carvalho Chehab did a mea culpa for accepting patches with non-kerneldoc header comments, but prefers fixing bugs and adding features to manually reformatting comments. Mauro prefers a tool that automates conversion from verious commenting styles, in particular, from Doxygen. Michal Simek doesn't see a problem with Doxygen in the kernel, instead asking that whatever approach is used should be used correctly.