FreeBSD devel/coccinelle semantic patches. Here are some coccinelle "semantic patches" that I have been running on FreeBSD, just for fun: arref.cocci Adjust array index. Hasn't found anything but looks interesting. bad_zero.cocci Checks for 0 being used for pointers instead of NULL. FreeBSD's sys should be clean now. Results on other parts of the OS may vary. One (rare) false positive. Avoid forcing C++ mode. ifaddr.cocci Reports checks of variable/field addresses. Hasn't found anything but looks interesting. mini_null_ref.cocci Finds easy-fixable NULL pointer de-reference. Fantastic: found two low-visibility bugs. mini_null_ref2.cocci Related to the above but not very useful. mini_null_ref3.cocci nitems.cocci Makes use of the nitems() array counting macro in sys/params.h. Only use on system files unless you don't care about portability. semicolon.cocci Removes unnecessary semicolons. FreeBSD should be clean now, except for some system-generated files. sz.cocci Correct code taking the size of a pointer. Hasn't found anything: I think we are well covered by static checkers here. unused.cocci Check if variables are only initialized and not used. We are probably well covered by compilers (GCC) already. xand.cocci Detect duplicated test. PVS detected some issues like this that have long been fixed. Produced a false positive in heimdal. roundup2.cocci FreeBSD specific use of roundup2 and rounddown2 macros. These have some relationship between them: roundup2 is a special case of roundown2 so the order is important. It misses some cases and is slow but is pretty good. A typical command line is like this: spatch --sp-file ~/cocci/bad_zero.cocci --in-place -dir /usr/src/sys/ Places to look for more semantic patches: http://coccinellery.org/ http://gitweb.dragonflybsd.org/dragonfly.git/tree/HEAD:/test/cocci