Re: [PATCH] headerdep: a tool for detecting inclusion cycles inheader files

From: Vegard Nossum
Date: Tue Dec 16 2008 - 06:51:20 EST


On Sat, Dec 13, 2008 at 11:22 PM, Sam Ravnborg <sam@xxxxxxxxxxxx> wrote:
> I tried to apply it and saw following output:
> In file included from linux/mmzone.h,
> from linux/topology.h
> from linux/mmzone.h
> from linux/gfp.h
> from linux/slub_def.h
> from linux/slab.h
> from linux/percpu.h
> from asm-generic/irq_regs.h
> include/asm-xtensa/irq_regs.h: warning: recursive header inclusion
>
> But looking at the file (include/asm-xtensa/irq_regs.h) did
> not help me understand where to look to fix it.

The program was run with include/asm-xtensa/irq_regs.h as input. So it
displays the whole chain of inclusion. The cycle is just the upper part:

> In file included from linux/mmzone.h,
> from linux/topology.h
> from linux/mmzone.h

...so that's where to look in general. I checked mmzone.h and topology.h,
and they do indeed include each other.

>
> Can you pinpoint the culprint better so this is becoming useful?

Line numbers would be nice, I agree. We can also have just the cycle stand
out a bit more. This is the new format:

$ perl scripts/headerdep.pl include/asm-xtensa/irq_regs.h
In file included from linux/mmzone.h,
from linux/topology.h:32
from linux/mmzone.h:763 <-- here
from linux/gfp.h:4
from linux/slub_def.h:10
from linux/slab.h:152
from linux/percpu.h:5
from asm-generic/irq_regs.h:15
include/asm-xtensa/irq_regs.h:1: warning: recursive header inclusion

> I would also like to see this integrated with checkincludes.pl
> as both script do some simple static checks of the header files.
>
> Additional bonus if we can reuse this to do better check of
> our exported headers.

This one is probably a bit too noisy? But if we can eliminate the existing
cycles, it would be nice, I agree. Thanks for the feedback! :)


Vegard