Re: PATCH: compile the kernel with -Werror

From: Dan Kegel (dkegel@ixiacom.com)
Date: Sat Jul 13 2002 - 16:31:14 EST


Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:

> On Sat, 2002-07-13 at 14:41, Roy Sigurd Karlsbakk wrote:
>> Why not add a menu item under kernel hacking?
>
> CONFIG_TEACH_USER_TO_USE_GREP

It's a bit challenging to grep for errors in gcc's output, as
gcc produces multiline errors and warnings.
Here's a perl script I whipped up yesterday to filter out
all but the errors and warnings from a make + gcc run
for some other project; it'd probably do nicely on kernel
builds. I use it like this:

     make > log 2>&1
     errfilter.pl log | more

It has the dubious feature that it properly filters out the
warnings gcc produces on .h files that don't end in newlines
(guess what IDE people use here?)
- Dan

--- errfilter.pl ---

#!/usr/bin/perl
# Filter out all but essential lines of the output of a make + gcc run.
# Dan Kegel dkegel@ixiacom.com 12 July 2002

# Join logical lines which have been split into multiple physical lines
while (<>) {
     chop;
     if (/^\S/) {
         &save($linebuf);
         $linebuf = "";
     }
     $linebuf .= $_;
}
# Force blank lines at end
&save($linebuf);
&save("");

# Handle next logical line. Handle lines of context, like 'Entering directory', properly.
sub save
{
     my($buf) = $_[0];

     # Remove excess space used at beginning of all but first physical
     # of a long logical line.
     $buf =~ s/ */ /g;

     if ($buf =~ /In file included from/) {
         # Handle include context.
         $prefix = $buf."\n";
     } elsif ($buf =~ /Entering directory/) {
         # Handle directory context.
         unshift(@dir, $buf."\n");
         $curdir = $dir[0];
     } elsif ($buf =~ /Leaving directory/) {
         # Handle directory context.
         shift(@dir);
         $curdir = $dir[0];
     } else {
         # Handle possible error lines.
         if (&filter($buf)) {
             # It's an error. Print it out with its context.
             print $curdir.$prefix.$buf;
             print "\n";
             # Dir context only gets printed out once per directory change.
             $curdir = "";
         }
         # Include context only gets printed out for immediately following line.
         $prefix = "";
     }
}

# Return true if given logical line contains a gcc error or warning and has not been seen before
sub filter
{
     my($line) = $_[0];

     if ($line =~ /:.*:/) {
         if ($line !~ /treated|sed.*\.d|no newline at end|warning: overriding commands|warning: ignoring old commands|File format not recognized/) {
             # uniq
             if ($out{$line} == 0) {
                 $out{$line}++;
                 return 1;
             }
         }
     }
     return 0;
}

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



This archive was generated by hypermail 2b29 : Mon Jul 15 2002 - 22:00:26 EST