linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: Christopher Li <sparse@chrisli.org>
Cc: sparse <linux-sparse@vger.kernel.org>
Subject: Re: Detect unused header files?
Date: Tue, 28 Jul 2009 22:58:08 +0200	[thread overview]
Message-ID: <20090728205808.GA20955@merkur.ravnborg.org> (raw)
In-Reply-To: <70318cbf0907281336p47b68b5cg44a3e7206646cb80@mail.gmail.com>

On Tue, Jul 28, 2009 at 01:36:26PM -0700, Christopher Li wrote:
> On Tue, Jul 28, 2009 at 11:18 AM, Sam Ravnborg<sam@ravnborg.org> 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.

Would be great...
If you can give some general into I can maybe give
it a shot albeit I have only very limited sprase
hacking knowledge.

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

The short version...
The header file that include the file is dependent
on the included file.

So if we:
- use (check/test/reference) a macro from the file => used
- use a typedef/struct
- ...
then we need the included header file.

> 
> > 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*
> file.
We do not care about this case...

The objective is to get the exported kernel headers as lean as possible.
This may occasionally break userland - but until now this has
been manageable.


If we apply this to kernel internal headers then we need to
do a bit of test builds to check things.
This is the same thing we do when we untange the include mess we have
today so we know what to do.
-next is btw a great help here.

If we do this inside spase or using a dedicated backend is not so important.
But adding this as a default=disabled option to sparse would be preferred.

	Sam

  parent reply	other threads:[~2009-07-28 20:58 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-28 18:18 Detect unused header files? Sam Ravnborg
2009-07-28 20:36 ` Christopher Li
2009-07-28 20:36   ` Robert P. J. Day
2009-07-28 20:49     ` Christopher Li
2009-07-28 21:04       ` Sam Ravnborg
2009-07-28 21:38         ` Christopher Li
2009-07-30 10:55           ` Christopher Li
2009-07-30 11:12             ` Derek M Jones
2009-07-30 20:36             ` Sam Ravnborg
2009-08-04 21:49               ` Christopher Li
2009-08-05  6:12                 ` Sam Ravnborg
2009-08-06 11:14                 ` Marko Kreen
2009-08-06 11:17                   ` Robert P. J. Day
2009-08-06 12:16                     ` Kamil Dudka
2009-08-06 12:15                       ` Robert P. J. Day
2009-08-06 13:01                       ` Kamil Dudka
2009-08-06 13:26                         ` Michael Stefaniuc
2009-08-06 14:09                           ` Robert P. J. Day
2009-08-06 17:39                   ` Christopher Li
2009-07-28 20:58   ` Sam Ravnborg [this message]
2009-07-28 21:21     ` Christopher Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090728205808.GA20955@merkur.ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).