mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	David Miller <davem@davemloft.net>,
	thomas@m3y3r.de, raven@themaw.net, linux-kernel@vger.kernel.org
Subject: Use gcc to check exported files [Was: Linux 3.3-rc4]
Date: Tue, 21 Feb 2012 19:26:02 +0100	[thread overview]
Message-ID: <20120221182602.GA23831@merkur.ravnborg.org> (raw)
In-Reply-To: <20120221130345.5c96ce60@pyramind.ukuu.org.uk>

On Tue, Feb 21, 2012 at 01:03:45PM +0000, Alan Cox wrote:
> > I'm starting to think we should compile the kernel with -Wpadded by
> > default (currently it's only done at "warning level 3", which I doubt
> > anyone ever uses, especially since that also includes -Wpacked which is
> > an actively toxic warning) and force people to add explicit padding
> > where it needs to go, if necessary.  Unfortunately even that doesn't
> > guarantee compatibility with userspace, but it's at least something.
> 
> We generate a set of believed correct export headers and check them these
> days as an option. Can that work not be turned to do this. Ie create a
> temporary .c file that includes all the user visible header data (without
> KERNEL being defined) and runs it through -Wpacked etc

Hi Alan.

If we require every exported file to be buildable on thier own
then it is simple to run gcc on every exported file.

We have before discussed that our header files should include everything
they need - and at least forcing this for our user-space headers would not be bad.

Simple hack I cooked up (will not work if you use O=...):

diff --git a/scripts/headers_check.pl b/scripts/headers_check.pl
index 7957e7a..b479575 100644
--- a/scripts/headers_check.pl
+++ b/scripts/headers_check.pl
@@ -27,12 +27,16 @@ my $line;
 my $lineno = 0;
 my $filename;
 
+my $gcc_options = "-Wall -Wpadded";
+my $gcc_include = "-I usr/include";
+
 foreach my $file (@files) {
 	$filename = $file;
 
 	open(my $fh, '<', $filename)
 		or die "$filename: $!\n";
 	$lineno = 0;
+	&check_build();
 	while ($line = <$fh>) {
 		$lineno++;
 		&check_include();
@@ -45,6 +49,13 @@ foreach my $file (@files) {
 }
 exit $ret;
 
+# Check that the header-file can build
+# All exported headers are assumed to include what they need
+sub check_build
+{
+	system("gcc -xc -c $gcc_include $gcc_options $filename")
+}
+
 sub check_include
 {
 	if ($line =~ m/^\s*#\s*include\s+<((asm|linux).*)>/) {


Now we just need someone to fix up the headers....
I counted around 870 errors in 160 files.
But 99% looked trivial to fix...

Almost all is a matter of adding one or a few missing includes.

	Sam


  reply	other threads:[~2012-02-21 18:26 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-19  0:27 Linux 3.3-rc4 Linus Torvalds
2012-02-19 13:42 ` Thomas Meyer
2012-02-19 18:45   ` Linus Torvalds
2012-02-19 19:49     ` David Miller
2012-02-19 20:02       ` Linus Torvalds
2012-02-20  3:28         ` Ian Kent
2012-02-21  3:29         ` Ian Kent
2012-02-21  3:38           ` Linus Torvalds
2012-02-21  4:02             ` Ian Kent
2012-02-21  4:17               ` Linus Torvalds
2012-02-21  4:52                 ` Ian Kent
2012-02-21  5:06                   ` Linus Torvalds
2012-02-21  5:21                     ` Linus Torvalds
2012-02-21  5:27                       ` H. Peter Anvin
2012-02-21  5:28                     ` H. Peter Anvin
2012-02-21  5:32                       ` Linus Torvalds
2012-02-21  5:39                     ` Ian Kent
2012-02-21  4:18           ` H. Peter Anvin
2012-02-21  4:22         ` H. Peter Anvin
2012-02-21 13:03           ` Alan Cox
2012-02-21 18:26             ` Sam Ravnborg [this message]
2012-02-21 18:58     ` Thomas Meyer
2012-02-21 22:07       ` Linus Torvalds
2012-02-21 22:43   ` Linus Torvalds
2012-02-21 23:10     ` Eric Dumazet
2012-02-21 23:19       ` Linus Torvalds
2012-02-24 10:39 ` Jiri Kosina
2012-02-24 16:52   ` Linus Torvalds
2012-02-24 18:01     ` Jiri Kosina
2012-02-24 18:21       ` Linus Torvalds
2012-02-29  8:38       ` Jiri Kosina

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=20120221182602.GA23831@merkur.ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=davem@davemloft.net \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=raven@themaw.net \
    --cc=thomas@m3y3r.de \
    --cc=torvalds@linux-foundation.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

all inboxes | Powered by JetHome®