Re: Detect unused header files?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

On Tue, Jul 28, 2009 at 11:18 AM, Sam Ravnborg<sam@xxxxxxxxxxxx> wrote:
> In the kernel we would like to avoid all
> unused include files.
> Especially in the headers we export to userspace.
> Are there any easy way we can use sparse to detect
> that a specific header file is not used?

I don't know a way to do that with current sparse.
We can implement some code for this.

We need to have a good definition of what is used.

> The header files I have in mind will be fully self-contained
> as they all include the header files they need to be used.

But a lot of case we have the header file is used in *another*

> Sample:
> cat foo.h:
> #include <linux/types.h>
> #include <linux/swab.h>
> struct foo {
>        __u32 bar;
>        __u32 baz;
> };
> Here <linux/swab.h> is obviously not used.
> And I would like sparse to flag this...

I don't think it is can be turn on by default.
What if some user space program want to include foo.h
and use the definitional inside "swab.h"? In that case it will
be OK. I don't think we can ban this kind of the usage case.

Looking at the header file itself is not good enough. It also depend
on how the user include it. What macro has been defined.
That will change the behavior of the header file as well.

To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at

[Index of Archives]     [Newbies FAQ]     [Kernel List]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

Powered by Linux