public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 1/1] markup_oops: fix perlcritic warnings
@ 2010-04-27 21:12 akpm
  2010-04-28  8:41 ` Michal Marek
  0 siblings, 1 reply; 5+ messages in thread
From: akpm @ 2010-04-27 21:12 UTC (permalink / raw)
  To: mmarek; +Cc: linux-kbuild, akpm, shemminger, amwang, arjan

From: Stephen Hemminger <shemminger@vyatta.com>

Turn on strict checking.
Use local file handles and 3 argument open.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Acked-by: WANG Cong <amwang@redhat.com>
Cc: Arjan van de Ven <arjan@infradead.org>
Cc: Michal Marek <mmarek@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 scripts/markup_oops.pl |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff -puN scripts/markup_oops.pl~markup_oops-fix-perlcritic-warnings scripts/markup_oops.pl
--- a/scripts/markup_oops.pl~markup_oops-fix-perlcritic-warnings
+++ a/scripts/markup_oops.pl
@@ -1,5 +1,7 @@
 #!/usr/bin/perl
 
+use strict;
+
 use File::Basename;
 use Math::BigInt;
 use Getopt::Long;
@@ -126,7 +128,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};
@@ -263,7 +265,7 @@ while (<FILE>) {
 	}
 }
 
-close(FILE);
+close($file);
 
 if ($counter == 0) {
 	print "No matching code found \n";
_

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch 1/1] markup_oops: fix perlcritic warnings
  2010-04-27 21:12 [patch 1/1] markup_oops: fix perlcritic warnings akpm
@ 2010-04-28  8:41 ` Michal Marek
  2010-04-28 23:17   ` Stephen Hemminger
  0 siblings, 1 reply; 5+ messages in thread
From: Michal Marek @ 2010-04-28  8:41 UTC (permalink / raw)
  To: akpm; +Cc: linux-kbuild, shemminger, amwang, arjan

On 27.4.2010 23:12, akpm@linux-foundation.org wrote:
> From: Stephen Hemminger <shemminger@vyatta.com>
> 
> Turn on strict checking.
> Use local file handles and 3 argument open.

Hi Andrew, Stephen,

as I wrote earlier, this patch is incomplete:
$ perl scripts/markup_oops.pl
Global symbol "$lastword" requires explicit package name at
scripts/markup_oops.pl line 110.
Global symbol "$clobber" requires explicit package name at
scripts/markup_oops.pl line 119.
Global symbol "$lastword" requires explicit package name at
scripts/markup_oops.pl line 119.
Global symbol "$clobber" requires explicit package name at
scripts/markup_oops.pl line 121.
Global symbol "$clobber" requires explicit package name at
scripts/markup_oops.pl line 123.
Global symbol "$clobber" requires explicit package name at
scripts/markup_oops.pl line 128.
Global symbol "$clobber" requires explicit package name at
scripts/markup_oops.pl line 132.
Global symbol "$lastword" requires explicit package name at
scripts/markup_oops.pl line 133.
Global symbol "$clobber" requires explicit package name at
scripts/markup_oops.pl line 143.
Global symbol "$lastword" requires explicit package name at
scripts/markup_oops.pl line 151.
Global symbol "$file" requires explicit package name at
scripts/markup_oops.pl line 268.
Execution of scripts/markup_oops.pl aborted due to compilation errors.

Please drop it from -mm.

Thanks,
Michal

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch 1/1] markup_oops: fix perlcritic warnings
  2010-04-28  8:41 ` Michal Marek
@ 2010-04-28 23:17   ` Stephen Hemminger
  2010-05-06 16:20     ` Michal Marek
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2010-04-28 23:17 UTC (permalink / raw)
  To: Michal Marek; +Cc: akpm, linux-kbuild, amwang, arjan

More complete patch, fixes all the warnings from perlcritic as
well as perl compiler with stictures enabled.

Compile tested, does some one have an actual oops output
to recheck it on?

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>


--- 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 (<FILE>) {
+	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 (<FILE>) {
+while (<$objdump>) {
 	my $line = $_;
 	chomp($line);
 	if ($state == 0) {
@@ -252,7 +255,7 @@ while (<FILE>) {
 	}
 }
 
-close(FILE);
+close($objdump);
 
 if ($counter == 0) {
 	print "No matching code found \n";

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch 1/1] markup_oops: fix perlcritic warnings
  2010-04-28 23:17   ` Stephen Hemminger
@ 2010-05-06 16:20     ` Michal Marek
  2010-05-10 18:09       ` Stephen Hemminger
  0 siblings, 1 reply; 5+ messages in thread
From: Michal Marek @ 2010-05-06 16:20 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: akpm, linux-kbuild, amwang, arjan

On 29.4.2010 01:17, Stephen Hemminger wrote:
> More complete patch, fixes all the warnings from perlcritic as
> well as perl compiler with stictures enabled.
> 
> Compile tested, does some one have an actual oops output
> to recheck it on?
> 
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

Hi Stephen,

could you please submit a patch against
git://repo.or.cz/linux-kbuild.git for-next (or linux-next or -mm) like
did in the last version?

Thanks,
Michal

> --- 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 (<FILE>) {
> +	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 (<FILE>) {
> +while (<$objdump>) {
>  	my $line = $_;
>  	chomp($line);
>  	if ($state == 0) {
> @@ -252,7 +255,7 @@ while (<FILE>) {
>  	}
>  }
>  
> -close(FILE);
> +close($objdump);
>  
>  if ($counter == 0) {
>  	print "No matching code found \n";
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch 1/1] markup_oops: fix perlcritic warnings
  2010-05-06 16:20     ` Michal Marek
@ 2010-05-10 18:09       ` Stephen Hemminger
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2010-05-10 18:09 UTC (permalink / raw)
  To: Michal Marek; +Cc: akpm, linux-kbuild, amwang, arjan

Cleanup of markup oops:
   * enable strict checking
   * fixes all the warnings from perlcritic
   * break some long lines.

Patch against kbuild for-next branch.
Compile tested, does some one have an actual oops output
to recheck it on?

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>


--- a/scripts/markup_oops.pl	2010-05-10 11:01:55.479688471 -0700
+++ b/scripts/markup_oops.pl	2010-05-10 11:07:08.951236561 -0700
@@ -1,5 +1,7 @@
 #!/usr/bin/perl
 
+use strict;
+
 use File::Basename;
 use Math::BigInt;
 use Getopt::Long;
@@ -17,7 +19,6 @@ use Getopt::Long;
 
 
 my $cross_compile = "";
-my $vmlinux_name = "";
 my $modulefile = "";
 
 # Get options
@@ -26,12 +27,13 @@ Getopt::Long::GetOptions(
 	'module|m=s'		=> \$modulefile,
 	'help|h'		=> \&usage,
 ) || usage ();
+
 my $vmlinux_name = $ARGV[0];
 if (!defined($vmlinux_name)) {
 	my $kerver = `uname -r`;
 	chomp($kerver);
 	$vmlinux_name = "/lib/modules/$kerver/build/vmlinux";
-	print "No vmlinux specified, assuming $vmlinux_name\n";
+	warn "No vmlinux specified, assuming $vmlinux_name\n";
 }
 my $filename = $vmlinux_name;
 
@@ -89,9 +91,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;
 }
 
@@ -104,17 +106,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
@@ -126,7 +126,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};
@@ -202,14 +202,16 @@ if ($module ne "") {
 		exit;
 	}
 	# ok so we found the module, now we need to calculate the vma offset
-	open(FILE, $cross_compile."objdump -dS $filename |") || die "Cannot start objdump";
-	while (<FILE>) {
-		if ($_ =~ /^([0-9a-f]+) \<$function\>\:/) {
-			my $fu = $1;
-			$vmaoffset = Math::BigInt->from_hex("0x$target") - Math::BigInt->from_hex("0x$fu") - Math::BigInt->from_hex("0x$func_offset");
-		}
+	open(my $obj, '-|', "objdump -dS $filename")
+	    or die "Cannot start objdump: $!";
+	while (<$obj>) {
+	    next unless ($_ =~ /^([0-9a-f]+) \<$function\>\:/);
+	    my $fu = $1;
+	    $vmaoffset = Math::BigInt->from_hex("0x$target")
+		- Math::BigInt->from_hex("0x$fu")
+		- Math::BigInt->from_hex("0x$func_offset");
 	}
-	close(FILE);
+	close($obj);
 }
 
 my $counter = 0;
@@ -234,10 +236,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(my $objdump, '-|',
+     "objdump -dS --adjust-vma=$vmaoffset --start-address=$decodestart --stop-address=$decodestop $filename")
+    or die "Cannot start objdump: $!";
 
-open(FILE, $cross_compile."objdump -dS --adjust-vma=$vmaoffset --start-address=$decodestart --stop-address=$decodestop $filename |") || die "Cannot start objdump";
-
-while (<FILE>) {
+while (<$objdump>) {
 	my $line = $_;
 	chomp($line);
 	if ($state == 0) {
@@ -263,7 +266,7 @@ while (<FILE>) {
 	}
 }
 
-close(FILE);
+close($objdump);
 
 if ($counter == 0) {
 	print "No matching code found \n";

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-05-10 18:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-27 21:12 [patch 1/1] markup_oops: fix perlcritic warnings akpm
2010-04-28  8:41 ` Michal Marek
2010-04-28 23:17   ` Stephen Hemminger
2010-05-06 16:20     ` Michal Marek
2010-05-10 18:09       ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox