Sparse

Sparse is a static type-checking program written specifically for the Linux kernel, written by Linus Torvalds. Support for running sparse is in the kernel build system.

That is, you can type "make C=1" and  will be executed on the C files that would be compiled. Type "make C=2" to run  on all C files in the kernel source tree.


 * Mailing list: http://vger.kernel.org/vger-lists.html#linux-sparse
 * Git snapshots: http://www.codemonkey.org.uk/projects/git-snapshots/sparse/
 * LWN.net article: http://lwn.net/Articles/87538/
 * sparse presentation: http://developer.osdl.org/dmo/sparse/

Usage notes from Randy Dunlap
From the "Quick sparse HOWTO, by Randy Dunlap: (located at http://www.xenotime.net/linux/doc/sparse_howto.txt)

=
========================================================= Quick sparse HOWTO Randy Dunlap 2004-JULY-25

in kernel tree, 'make help' says:

make C=1  [targets] Check all c source with checker tool

To build & install sparse:

"checker tool" is built as "check" but then installed as "sparse".

a. unpack the tarball or export the bk tree b. cd path/to/sparse c. make d. make install     # default location is in user's $HOME/bin

...then do your target build, e.g.,

make allmodconfig    # or defconfig or whatever make C=1 all >build.out 2>&1    # to capture all messages

...

Usage notes from Linus Torvalds
Linus said:

>>[Where to get sparse? I tried to google for it but "sparse" is >> very common word (as in sparse matrix). And theres no >> kernel/people/linus on kernel.org...]

...

If you search for "sparse checker linux" you'll find a number of hits..

Once you have it, just do

make make install

as your regular user, and it will install sparse in your ~/bin directory. After that, doing a kernel make with "make C=1" will run sparse on all the C files that get recompiled, or with "make C=2" will run sparse on the files whether they need to be recompiled or not (ie the latter is fast way to check the whole tree if you have already built it).