From: Dan Carpenter <dan.carpenter@oracle.com>
To: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: "ksummit-discuss@lists.linuxfoundation.org"
<ksummit-discuss@lists.linuxfoundation.org>
Subject: Re: [Ksummit-discuss] [TOPIC] Encouraging more reviewers
Date: Fri, 30 May 2014 14:17:30 +0300 [thread overview]
Message-ID: <20140530111730.GH15585@mwanda> (raw)
In-Reply-To: <1401423973.2163.26.camel@dabdike>
[-- Attachment #1: Type: text/plain, Size: 276 bytes --]
I use a script to help review cleanup patches. It chops out the white
space, the comment changes and bracing changes. If there is a variable
renamed then I can strip that out as well when you
`cat patch | rename_rev.pl OldName new_name`.
Attached.
regards,
dan carpenter
[-- Attachment #2: rename_rev.pl --]
[-- Type: text/x-perl, Size: 5104 bytes --]
#!/usr/bin/perl
# This is a tool to help review variable rename patches. The goal is
# to strip out the automatic sed renames and the white space changes
# and leaves the interesting code changes.
#
# Example 1: A patch renames openInfo to open_info:
# cat diff | rename_review.pl openInfo open_info
#
# Example 2: A patch swaps the first two arguments to some_func():
# cat diff | rename_review.pl \
# -e 's/some_func\((.*?),(.*?),/some_func\($2, $1,/'
#
# Example 3: A patch removes the xkcd_ prefix from some but not all the
# variables. Instead of trying to figure out which variables were renamed
# just remove the prefix from them all:
# cat diff | rename_review.pl -ea 's/xkcd_//g'
#
# Example 4: A patch renames 20 CamelCase variables. To review this let's
# just ignore all case changes and all '_' chars.
# cat diff | rename_review -ea 'tr/[A-Z]/[a-z]/' -ea 's/_//g'
#
# The other arguments are:
# -nc removes comments
# -ns removes '\' chars if they are at the end of the line.
use strict;
use File::Temp qw/ :mktemp /;
sub usage() {
print "usage: cat diff | $0 old new old new old new...\n";
print " or: cat diff | $0 -e 's/old/new/g'\n";
print " -e : execute on old lines\n";
print " -ea: execute on all lines\n";
print " -nc: no comments\n";
print " -nb: no unneeded braces\n";
print " -ns: no slashes at the end of a line\n";
exit(1);
}
my @subs;
my @cmds;
my $strip_comments;
my $strip_braces;
my $strip_slashes;
sub filter($) {
my $_ = shift();
my $old = 0;
if ($_ =~ /^-/) {
$old = 1;
}
# remove the first char
s/^[ +-]//;
if ($strip_comments) {
s/\/\*.*?\*\///g;
s/\/\/.*//;
}
foreach my $cmd (@cmds) {
if ($old || $cmd->[0] =~ /^-ea$/) {
eval $cmd->[1];
}
}
foreach my $sub (@subs) {
if ($old) {
s/$sub->[0]/$sub->[1]/g;
}
}
# remove the newline so we can move curly braces here if we want.
s/\n//;
return $_;
}
while (my $param1 = shift()) {
if ($param1 =~ /^-nc$/) {
$strip_comments = 1;
next;
}
if ($param1 =~ /^-nb$/) {
$strip_braces = 1;
next;
}
if ($param1 =~ /^-ns$/) {
$strip_slashes = 1;
next;
}
my $param2 = shift();
if ($param2 =~ /^$/) {
usage();
}
if ($param1 =~ /^-e(a|)$/) {
push @cmds, [$param1, $param2];
next;
}
push @subs, [$param1, $param2];
}
my ($oldfh, $oldfile) = mkstemp("/tmp/oldXXXXX");
my ($newfh, $newfile) = mkstemp("/tmp/newXXXXX");
my $started = 0;
my $output;
#recreate an old file and a new file
while (<>) {
if ($_ =~ /^(---|\+\+\+)/) {
next;
}
if ($_ =~ /^@/) {
$started = 1;
}
if ($started && !($_ =~ /^[- @+]/)) {
last;
}
$output = filter($_);
if ($strip_braces && $_ =~ /^(\+|-)\W+{/) {
$output =~ s/^[\t ]+(.*)/ $1/;
} else {
$output = "\n" . $output;
}
if ($_ =~ /^-/) {
print $oldfh $output;
next;
}
if ($_ =~ /^\+/) {
print $newfh $output;
next;
}
print $oldfh $output;
print $newfh $output;
}
print $oldfh "\n";
print $newfh "\n";
# git diff puts a -- and version at the end of the diff. put the -- into the
# new file as well so it's ignored
if ($output =~ /\n-/) {
print $newfh "-\n";
}
my $hunk;
my $old_txt;
my $new_txt;
open diff, "diff -uw $oldfile $newfile |";
while (<diff>) {
if ($_ =~ /^(---|\+\+\+)/) {
next;
}
if ($_ =~ /^@/) {
if ($strip_comments) {
$old_txt =~ s/\/\*.*?\*\///g;
$new_txt =~ s/\/\*.*?\*\///g;
}
if ($strip_braces) {
$old_txt =~ s/{([^;{]*?);}/$1;/g;
$new_txt =~ s/{([^;{]*?);}/$1;/g;
# this is a hack because i don't know how to replace nested
# unneeded curly braces.
$old_txt =~ s/{([^;{]*?);}/$1;/g;
$new_txt =~ s/{([^;{]*?);}/$1;/g;
}
if ($old_txt ne $new_txt) {
print $hunk;
print $_;
}
$hunk = "";
$old_txt = "";
$new_txt = "";
next;
}
$hunk = $hunk . $_;
if ($strip_slashes) {
s/\\$//;
}
if ($_ =~ /^-/) {
s/-//;
s/[ \t\n]//g;
$old_txt = $old_txt . $_;
next;
}
if ($_ =~ /^\+/) {
s/\+//;
s/[ \t\n]//g;
$new_txt = $new_txt . $_;
next;
}
if ($_ =~ /^ /) {
s/^ //;
s/[ \t\n]//g;
$old_txt = $old_txt . $_;
$new_txt = $new_txt . $_;
}
}
if ($old_txt ne $new_txt) {
if ($strip_comments) {
$old_txt =~ s/\/\*.*?\*\///g;
$new_txt =~ s/\/\*.*?\*\///g;
}
if ($strip_braces) {
$old_txt =~ s/{([^;{]*?);}/$1;/g;
$new_txt =~ s/{([^;{]*?);}/$1;/g;
$old_txt =~ s/{([^;{]*?);}/$1;/g;
$new_txt =~ s/{([^;{]*?);}/$1;/g;
}
print $hunk;
}
unlink($oldfile);
unlink($newfile);
print "\ndone.\n";
next prev parent reply other threads:[~2014-05-30 11:17 UTC|newest]
Thread overview: 166+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-24 9:53 James Bottomley
2014-05-24 11:19 ` Wolfram Sang
2014-05-24 19:18 ` Guenter Roeck
2014-05-25 4:56 ` NeilBrown
2014-05-25 4:57 ` James Bottomley
2014-05-26 15:41 ` Guenter Roeck
2014-05-30 16:05 ` mark gross
2014-05-30 16:45 ` Guenter Roeck
2014-06-01 14:05 ` Wolfram Sang
2014-05-25 8:59 ` Wolfram Sang
2014-05-26 12:23 ` Rafael J. Wysocki
2014-05-26 12:52 ` Wolfram Sang
2014-05-27 17:27 ` Lukáš Czerner
2014-05-27 22:57 ` Rafael J. Wysocki
2014-05-27 22:43 ` Andy Lutomirski
2014-05-27 23:09 ` Rafael J. Wysocki
2014-05-28 14:26 ` Daniel Vetter
2014-05-28 14:32 ` Dan Carpenter
2014-05-28 14:39 ` Daniel Vetter
2014-05-28 16:39 ` Mark Brown
2014-05-28 16:51 ` Mimi Zohar
2014-05-28 17:35 ` Mark Brown
2014-05-28 17:44 ` Luck, Tony
2014-05-28 18:38 ` Mark Brown
2014-05-28 21:32 ` Thomas Gleixner
2014-05-29 9:28 ` Li Zefan
2014-05-29 17:41 ` Greg KH
2014-05-30 2:41 ` Li Zefan
2014-05-30 17:28 ` Paul E. McKenney
2014-05-30 23:40 ` Greg KH
2014-05-31 16:49 ` Geert Uytterhoeven
2014-06-01 8:36 ` Takashi Iwai
2014-05-31 23:30 ` Randy Dunlap
2014-05-29 18:43 ` Steven Rostedt
2014-05-28 22:48 ` Daniel Vetter
2014-05-28 23:17 ` Laurent Pinchart
2014-05-29 18:45 ` Steven Rostedt
2014-05-29 7:35 ` Dan Carpenter
2014-05-28 16:05 ` Guenter Roeck
2014-05-28 16:37 ` Mimi Zohar
2014-05-28 16:50 ` Guenter Roeck
2014-05-28 16:20 ` Mimi Zohar
2014-05-28 16:28 ` Josh Triplett
2014-05-28 17:05 ` Jonathan Corbet
2014-05-28 21:59 ` Thomas Gleixner
2014-05-28 23:31 ` josh
2014-05-28 23:55 ` Thomas Gleixner
2014-05-29 0:39 ` Mimi Zohar
2014-05-29 0:47 ` Randy Dunlap
2014-05-29 0:52 ` Mimi Zohar
2014-05-29 6:13 ` James Bottomley
2014-05-29 18:58 ` Steven Rostedt
2014-05-29 23:34 ` Greg KH
2014-05-30 2:23 ` Li Zefan
2014-05-30 4:26 ` James Bottomley
2014-05-30 5:02 ` Greg KH
2014-05-30 5:33 ` James Bottomley
2014-05-30 14:14 ` John W. Linville
2014-05-30 16:40 ` Theodore Ts'o
2014-05-30 16:43 ` Theodore Ts'o
2014-05-30 16:56 ` [Ksummit-discuss] More productive uses of enthusiastic new kernel developers (was: Re: [TOPIC] Encouraging more reviewers) Theodore Ts'o
2014-05-30 19:54 ` Shuah Khan
2014-06-02 12:00 ` Jason Cooper
2014-05-30 20:50 ` David Woodhouse
2014-05-31 1:44 ` [Ksummit-discuss] More productive uses of enthusiastic new kernel developers Li Zefan
2014-05-31 1:54 ` Guenter Roeck
2014-05-31 2:21 ` Theodore Ts'o
2014-05-31 22:53 ` Rafael J. Wysocki
2014-05-31 2:07 ` Theodore Ts'o
2014-05-31 3:52 ` Greg KH
2014-05-31 4:08 ` Guenter Roeck
2014-05-30 23:47 ` [Ksummit-discuss] [TOPIC] Encouraging more reviewers Greg KH
2014-05-30 11:17 ` Dan Carpenter [this message]
2014-05-31 21:05 ` Dan Carpenter
2014-05-29 10:31 ` Daniel Vetter
2014-05-29 18:36 ` Greg KH
2014-05-29 15:32 ` Luck, Tony
2014-05-28 5:37 ` Wolfram Sang
2014-05-28 10:06 ` Lukáš Czerner
2014-05-28 13:57 ` Wolfram Sang
2014-05-24 14:24 ` Dan Williams
2014-05-26 12:31 ` Rafael J. Wysocki
2014-05-24 15:50 ` Trond Myklebust
2014-05-24 17:31 ` James Bottomley
2014-05-25 4:15 ` Bjorn Helgaas
2014-05-26 12:38 ` Rafael J. Wysocki
2014-05-27 18:21 ` H. Peter Anvin
2014-05-25 4:17 ` Stephen Rothwell
2014-05-25 8:53 ` Geert Uytterhoeven
2014-05-25 9:11 ` Stephen Rothwell
2014-05-27 8:16 ` Li Zefan
2014-05-25 9:09 ` Wolfram Sang
2014-05-25 22:29 ` Dan Carpenter
2014-05-26 15:53 ` James Bottomley
2014-05-27 14:39 ` Jiri Kosina
2014-05-27 20:53 ` James Bottomley
2014-05-27 21:22 ` Jiri Kosina
2014-05-28 0:10 ` Martin K. Petersen
2014-05-28 0:30 ` Greg KH
2014-05-28 23:25 ` Dan Williams
2014-05-28 23:32 ` Jiri Kosina
2014-05-28 23:47 ` Dan Williams
2014-05-29 4:01 ` Martin K. Petersen
2014-05-29 5:17 ` Dan Williams
2014-05-29 23:56 ` Martin K. Petersen
2014-05-29 23:59 ` Dan Williams
2014-05-28 23:33 ` Rafael J. Wysocki
2014-05-29 0:35 ` Ben Hutchings
2014-05-29 4:36 ` Martin K. Petersen
2014-05-29 16:46 ` Mark Brown
2014-05-29 21:57 ` Frank Rowand
2014-05-29 23:12 ` Mark Brown
2014-05-28 1:10 ` NeilBrown
2014-05-28 5:11 ` James Bottomley
2014-05-26 12:17 ` Rafael J. Wysocki
2014-05-28 18:47 ` Paul Walmsley
2014-05-28 20:15 ` josh
2014-05-29 2:15 ` Rob Herring
2014-05-29 3:34 ` Olof Johansson
2014-05-30 0:52 ` Paul Walmsley
2014-05-29 8:39 ` Jonathan Cameron
2014-05-30 0:47 ` Paul Walmsley
2014-05-30 0:51 ` Paul Walmsley
2014-05-28 18:48 ` [Ksummit-discuss] Reforming Acked-by (was Re: [TOPIC] Encouraging more reviewers) Paul Walmsley
2014-05-28 19:11 ` Mimi Zohar
2014-05-28 19:15 ` John W. Linville
2014-05-28 19:51 ` Mimi Zohar
2014-05-30 14:59 ` Steven Rostedt
2014-05-30 15:10 ` John W. Linville
2014-05-30 21:10 ` James Bottomley
2014-05-30 21:30 ` Steven Rostedt
2014-06-02 2:43 ` Randy Dunlap
2014-06-02 2:53 ` NeilBrown
2014-06-02 3:01 ` Randy Dunlap
2014-05-28 19:49 ` Guenter Roeck
2014-05-28 20:12 ` josh
2014-05-28 20:22 ` Dmitry Torokhov
2014-05-28 23:02 ` Laurent Pinchart
2014-05-28 23:18 ` Dmitry Torokhov
2014-05-28 23:29 ` Laurent Pinchart
2014-05-29 14:44 ` Christoph Lameter
2014-05-29 14:59 ` Laurent Pinchart
2014-05-29 16:33 ` Christoph Lameter
2014-05-30 10:58 ` Laurent Pinchart
2014-05-29 15:58 ` H. Peter Anvin
2014-05-29 18:27 ` Theodore Ts'o
2014-05-29 21:03 ` Rafael J. Wysocki
2014-05-29 21:03 ` Olof Johansson
2014-05-29 23:30 ` Greg KH
2014-05-30 1:12 ` Paul Walmsley
2014-05-30 5:04 ` Greg KH
2014-05-30 5:39 ` James Bottomley
2014-05-30 11:30 ` Daniel Vetter
2014-05-30 23:39 ` Greg KH
2014-05-30 10:08 ` Lukáš Czerner
2014-05-30 13:07 ` Jan Kara
2014-05-30 13:41 ` Lukáš Czerner
2014-05-30 15:22 ` Steven Rostedt
2014-05-31 1:30 ` Li Zefan
2014-05-30 14:34 ` John W. Linville
2014-05-30 0:55 ` Paul Walmsley
2014-05-30 15:17 ` Steven Rostedt
2014-05-30 15:06 ` Steven Rostedt
2014-05-30 21:26 ` Rafael J. Wysocki
2014-05-30 21:29 ` Steven Rostedt
2014-05-30 22:16 ` Rafael J. Wysocki
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=20140530111730.GH15585@mwanda \
--to=dan.carpenter@oracle.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=ksummit-discuss@lists.linuxfoundation.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