Re: whose job is it to include various header files?

From: Robert P. J. Day
Date: Thu Mar 13 2008 - 21:02:39 EST


On Fri, 14 Mar 2008, Jesper Juhl wrote:

> On 13/03/2008, Robert P. J. Day <rpjday@xxxxxxxxxxxxxx> wrote:
> >
> > more a philosophy question than anything but, while poking around
> > the percpu stuff today, i noticed in the header file linux/percpu.h
> > the opening snippet:
> >
> > #include <linux/preempt.h>
> > #include <linux/slab.h> /* For kmalloc() */
> > #include <linux/smp.h>
> > #include <linux/string.h> /* For memset() */
> > #include <linux/cpumask.h>
> > ...

> I agree with you completely. A file should explicitly include
> headers for the stuff it uses and not rely on implicit includes done
> elsewhere. Cleaning that up is going to touch a lot of files though
> for no real short term gain (there is a long term gain of
> maintainability though), so it's going to be a loveless job :(

i wasn't about to run off and start changing stuff, i was just curious
about the general philosophy. i *might* see the value of a patch if
it's a cleanup that affects a restricted set of files that are
logically related and can be done with a single patch. beyond that,
no.

the only reason the above example caught my eye is the insistence in
the comments as to why those includes were there, when there were no
invocations of those routines anywhere in the file. i always find
that curious.

rday
--


========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry:
Have classroom, will lecture.

http://crashcourse.ca Waterloo, Ontario, CANADA
========================================================================
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/