From patchwork Wed Apr 28 23:17:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 95828 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3SNHr5j003514 for ; Wed, 28 Apr 2010 23:17:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932287Ab0D1XRw (ORCPT ); Wed, 28 Apr 2010 19:17:52 -0400 Received: from mail.vyatta.com ([76.74.103.46]:37617 "EHLO mail.vyatta.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752470Ab0D1XRv (ORCPT ); Wed, 28 Apr 2010 19:17:51 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.vyatta.com (Postfix) with ESMTP id 66F0D4F4341; Wed, 28 Apr 2010 16:17:46 -0700 (PDT) X-Virus-Scanned: amavisd-new at tahiti.vyatta.com Received: from mail.vyatta.com ([127.0.0.1]) by localhost (mail.vyatta.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FToLy4UP2Z1q; Wed, 28 Apr 2010 16:17:33 -0700 (PDT) Received: from nehalam (pool-74-107-135-205.ptldor.fios.verizon.net [74.107.135.205]) by mail.vyatta.com (Postfix) with ESMTP id D471A4F4271; Wed, 28 Apr 2010 16:17:32 -0700 (PDT) Date: Wed, 28 Apr 2010 16:17:31 -0700 From: Stephen Hemminger To: Michal Marek Cc: akpm@linux-foundation.org, linux-kbuild@vger.kernel.org, amwang@redhat.com, arjan@infradead.org Subject: Re: [patch 1/1] markup_oops: fix perlcritic warnings Message-ID: <20100428161731.054fbd19@nehalam> In-Reply-To: <4BD7F4C8.4080107@suse.cz> References: <201004272112.o3RLCrlB020200@imap1.linux-foundation.org> <4BD7F4C8.4080107@suse.cz> Organization: Vyatta X-Mailer: Claws Mail 3.7.5 (GTK+ 2.18.3; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 28 Apr 2010 23:18:02 +0000 (UTC) --- a/scripts/markup_oops.pl 2010-04-28 16:05:20.794776102 -0700 +++ b/scripts/markup_oops.pl 2010-04-28 16:15:24.894377031 -0700 @@ -1,5 +1,7 @@ #!/usr/bin/perl +use strict; + use File::Basename; use Math::BigInt; @@ -79,9 +81,9 @@ sub parse_x86_regs sub reg_name { my ($reg) = @_; - $reg =~ s/r(.)x/e\1x/; - $reg =~ s/r(.)i/e\1i/; - $reg =~ s/r(.)p/e\1p/; + $reg =~ s/r(.)x/e$1x/; + $reg =~ s/r(.)i/e$1i/; + $reg =~ s/r(.)p/e$1p/; return $reg; } @@ -94,17 +96,15 @@ sub process_x86_regs } # find the arguments to the instruction - if ($line =~ /([0-9a-zA-Z\,\%\(\)\-\+]+)$/) { - $lastword = $1; - } else { - return ""; - } + return "" unless ($line =~ /([0-9a-zA-Z\,\%\(\)\-\+]+)$/); + + my $lastword = $1; # we need to find the registers that get clobbered, # since their value is no longer relevant for previous # instructions in the stream. - $clobber = $lastword; + my $clobber = $lastword; # first, remove all memory operands, they're read only $clobber =~ s/\([a-z0-9\%\,]+\)//g; # then, remove everything before the comma, thats the read part @@ -116,7 +116,7 @@ sub process_x86_regs $clobber = ""; } - foreach $reg (keys(%regs)) { + foreach my $reg (keys(%regs)) { my $clobberprime = reg_name($clobber); my $lastwordprime = reg_name($lastword); my $val = $regs{$reg}; @@ -192,14 +192,15 @@ if ($module ne "") { exit; } # ok so we found the module, now we need to calculate the vma offset - open(FILE, "objdump -dS $filename |") || die "Cannot start objdump"; - while () { + open(my $obj, '-|', "objdump -dS $filename") + || die "Cannot start objdump: $!"; + while (<$obj>) { if ($_ =~ /^([0-9a-f]+) \<$function\>\:/) { my $fu = $1; $vmaoffset = hex($target) - hex($fu) - hex($func_offset); } } - close(FILE); + close($obj); } my $counter = 0; @@ -225,9 +226,11 @@ sub InRange { # first, parse the input into the lines array, but to keep size down, # we only do this for 4Kb around the sweet spot -open(FILE, "objdump -dS --adjust-vma=$vmaoffset --start-address=$decodestart --stop-address=$decodestop $filename |") || die "Cannot start objdump"; +open(my $objdump, '-|', + "objdump -dS --adjust-vma=$vmaoffset --start-address=$decodestart --stop-address=$decodestop $filename") + or die "Cannot start objdump: $!"; -while () { +while (<$objdump>) { my $line = $_; chomp($line); if ($state == 0) { @@ -252,7 +255,7 @@ while () { } } -close(FILE); +close($objdump); if ($counter == 0) { print "No matching code found \n";