public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Kegel <dkegel@ixiacom.com>
To: linux-kernel@vger.kernel.org
Subject: Re: PATCH: compile the kernel with -Werror
Date: Sat, 13 Jul 2002 14:31:14 -0700	[thread overview]
Message-ID: <3D309C22.902@ixiacom.com> (raw)

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;
}




             reply	other threads:[~2002-07-13 20:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-13 21:31 Dan Kegel [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-07-13  7:26 PATCH: compile the kernel with -Werror Muli Ben-Yehuda
2002-07-13  8:02 ` Zwane Mwaikambo
2002-07-13  7:43   ` Muli Ben-Yehuda
2002-07-13 14:49     ` Thunder from the hill
2002-07-13  8:17 ` Mike Galbraith
2002-07-13 13:10 ` Kenneth Johansson
2002-07-13 13:41 ` Roy Sigurd Karlsbakk
2002-07-13 14:59   ` Alan Cox
2002-07-16 20:36   ` James Antill
2002-07-13 14:24 ` Alan Cox
2002-07-13 13:34   ` William Lee Irwin III
2002-07-13 18:46   ` Linus Torvalds

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=3D309C22.902@ixiacom.com \
    --to=dkegel@ixiacom.com \
    --cc=linux-kernel@vger.kernel.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