[ANNOUNCE] headercheck - check dependencies on header files

From: Sam Ravnborg
Date: Thu Apr 09 2009 - 16:40:35 EST


We have at several occasions discussed if our header files
should include their dependencies or not.

But we were lacking a tool to tell us if our header files
included the headerfiles they needed or not.

headercheck can be used to do so.

headercheck use the existing Kbuild files in
include/ to determine which directories to visit.

And for each directory it create one .c file for each
.h file and build it.

A .c file looks like this:

$cat module.h.c
#include <linux/module.h>


Building this file will tell us if module.h is
missing any dependencies (but NOT if it has too many) with
the current configuration.

We know that some header files are simply NOT supposed to be included
direct and thus is not eligble to such a check.

To avoid checking these we can say in Kbuild:

ignore-y += compiler-gcc.h

This tells headercheck to ignore compiler-gcc.h when performing
the headercheck.

The current implementation leaves a lot of .c files.
I will address this if the concept is considered acceptable.

To visit all relevant directories we need to adjust the Kbuild
files but that can wait until we have the current pile fixed.
Likewise it does not support arch specific include files.
That can wait too.

I have tried running headercheck on an i386 defconfig and
the result shows that a lot af headers does not include there
dependencies.

The numbers (including sub-directories):

25 include/asm-generic
12 include/drm
282 include/linux
2 include/mtd
24 include/sound
12 include/video

Remember we do not visit all directories - only those listed in include/Kbuild.

To try it yourself apply following patch and on a configured kernel use:

make -k headercheck

Looking at the errors I would assume that at least 75% of the errors
can be fixed in one day but the rest may be a bit more troublesome.

The open question is if this is worthwhile?

Sam