Re: RFC: cleaning up the in-kernel headers

Adrian Bunk
2006-07-11T22:24:05Z

On Tue, Jul 11, 2006 at 05:28:43PM +0100, David Woodhouse wrote:
> On Tue, 2006-07-11 at 18:06 +0200, Adrian Bunk wrote:
> > I'd like to cleanup the mess of the in-kernel headers, based on the
> > following rules:
> > - every header should #include everything it uses
> > - remove unneeded #include's from headers
> >
> > This would also remove all the implicit rules "before #include'ing
> > header foo.h, you must #include header bar.h" you usually only see
> > when the compilation fails.
> >
> > There might be exceptions (e.g. for avoiding circular #include's) but
> > these would be special cases.
>
> Seems eminently sensible. Please make sure you don't introduce
> regressions in the output of 'make headers_install' by unconditionally
> including files which don't exist in the export -- if something is only
> _used_ within #ifdef __KERNEL__ then it should only be #included within
> #ifdef __KERNEL__ too.

Sure, I have the userspace headers in mind, too.

> It would be nice in the general case if we could actually _compile_ each
> header file, standalone. There may be some cases where that doesn't
> work, but it's a useful goal in most cases, for bother exported headers
> _and_ the in-kernel version. For the former case it would be nice to add
> it to 'make headers_check' once it's realistic to do so.

That's what I meant with "every header should #include everything it
uses".

Unfortunately, compiling alone is not enough due to:
- different config options affecting a header
- code only used in a #define

I got a problem caused by the combination of both just a few days ago...

>...
> dwmw2

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed