Re: + remove-current-defines-and-uses-of-pr_err-add-pr_emerg.patch added to -mm tree

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

 



On Sat, 2007-08-04 at 18:47 +0200, Jean Delvare wrote:
> On 8/4/2007, "Jan Engelhardt" <[email protected]> wrote: 
> >Ugh. What do we have printk for then? I do not like this.
> >For pr_debug() it makes sense because its semantics change with
> >-DDEBUG and -UDEBUG, but for these pr_()s it does not seem so.
> I think I agree with Jan here, I see no fundamental need for these
> additional macros. But if they are really added, then they should follow
> the same standard as pr_debug() and pr_info(), that is: no "\n" added
> automatically. Otherwise this will become quite messy.

2 reasons:

This change will eventually isolate multiple line
printk messages and allow easier insertion of 

printk_block_start
printks
printk_block_end

so that multiple line messages are kept together
in the message logs.

and I've done tree-wide patches for single line

printk(KERN_\(emerg|alert|notice|crit\),

(about 2000) and fixed several dozen lines without \n
or things like "KERN_<level> /n msg"

Here's the perl script I used.

It's imperfect of course.  There are comments with
embedded semicolons where it fails, and #defines
aren't substituted too well.

if ($#ARGV < 2) {
    print "usage: KERN_<level> pr_<level> files...\n";
    exit;
}

for ($i=2; $i <= $#ARGV; $i++) {
    PrintkSearchReplace($ARGV[$i], $ARGV[0], $ARGV[1]);
}

sub PrintkSearchReplace{
    my($file, $search, $replace) = @_;

    my $orig = "";
    local($/);
    open(my $fh, $file) or die "File not found '$file'\n";
    $orig = <$fh>;
    close(my $fh);

    my $parts = $orig;
    my $whole = "";
    @segments = split(/\;/, $parts);
    foreach $line (@segments) {

	if ($whole ne "") {
	    $whole = $whole . "\;";
	}

	my $origline = $line;

	if ($line =~ m/\bprintk\s*\(\s*${search}\s*.*\".*\\n\s*\"/ms) {
	    
	    $line =~ s/\bprintk\s*\(\s*${search}\s*([^\"]*)\"/${replace}\(\1\"/ms;
	    $line =~ s/\\n\s*\"\s*/\"/ms;

	    print "${file}: changed:\n" . $origline . "\;" . "\nto:\n" . $line . "\;" . "\n" ;

	}
	$whole = $whole . $line;
    }

    if ($orig ne $whole) {
	open(my $fh, ">${file}") or die "Could not open '$file'\n";
	print $fh $whole;
	close(my $fh);
    }

}


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

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux