aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandrakesoft.com>2004-06-17 18:07:37 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-06-17 18:07:37 -0700
commitee4a77fcabba290f0186357409a05aab184837c8 (patch)
treeb707ad3c6a489b662b47fcc8f3b1e2e48e1023fe /scripts
parenta68a29d93f1ef19871d7b376ab8f82057e2dcf77 (diff)
downloadhistory-ee4a77fcabba290f0186357409a05aab184837c8.tar.gz
[PATCH] checksatck.pl fixes
- "\<" and "\>" can be safely replaced with "<" and ">" - "$var =~ /^string$/" is better written "$var eq 'string'" - $i is better written without the double quotes - it's not safe to use for without "my"ing the iteration variable - "print foreach @array" is better written "print @array" - declare variables - ".*" is useless at the end of a regexp - "$a[@a] = $foo" is a rather obfuscated syntax for "push @a, $foo"... let's not opencoding language basic operators... - ignoring return value from a regexp is very bad: this can results in working on previous value of $1, $2, ... Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/checkstack.pl29
1 files changed, 14 insertions, 15 deletions
diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
index df85c66caa0ad6..073704ef6a6cec 100644
--- a/scripts/checkstack.pl
+++ b/scripts/checkstack.pl
@@ -23,6 +23,7 @@
# $1 (first bracket) matches the size of the stack growth
#
# use anything else and feel the pain ;)
+my (@stack, $re, $x, $xs);
{
my $arch = shift;
if ($arch eq "") {
@@ -31,25 +32,25 @@
$x = "[0-9a-f]"; # hex character
$xs = "[0-9a-f ]"; # hex character or space
- if ($arch =~ /^arm$/) {
+ if ($arch eq 'arm') {
#c0008ffc: e24dd064 sub sp, sp, #100 ; 0x64
$re = qr/.*sub.*sp, sp, #(([0-9]{2}|[3-9])[0-9]{2})/o;
} elsif ($arch =~ /^i[3456]86$/) {
#c0105234: 81 ec ac 05 00 00 sub $0x5ac,%esp
$re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%esp$/o;
- } elsif ($arch =~ /^ia64$/) {
+ } elsif ($arch eq 'ia64') {
#e0000000044011fc: 01 0f fc 8c adds r12=-384,r12
$re = qr/.*adds.*r12=-(([0-9]{2}|[3-9])[0-9]{2}),r12/o;
- } elsif ($arch =~ /^mips64$/) {
+ } elsif ($arch eq 'mips64') {
#8800402c: 67bdfff0 daddiu sp,sp,-16
$re = qr/.*daddiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
- } elsif ($arch =~ /^mips$/) {
+ } elsif ($arch eq 'mips') {
#88003254: 27bdffe0 addiu sp,sp,-32
$re = qr/.*addiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
- } elsif ($arch =~ /^ppc$/) {
+ } elsif ($arch eq 'ppc') {
#c00029f4: 94 21 ff 30 stwu r1,-208(r1)
$re = qr/.*stwu.*r1,-($x{1,8})\(r1\)/o;
- } elsif ($arch =~ /^ppc64$/) {
+ } elsif ($arch eq 'ppc64') {
#XXX
$re = qr/.*stdu.*r1,-($x{1,8})\(r1\)/o;
} elsif ($arch =~ /^s390x?$/) {
@@ -62,6 +63,7 @@
}
sub bysize($) {
+ my ($asize, $bsize);
($asize = $a) =~ s/.* +(.*)$/$1/;
($bsize = $b) =~ s/.* +(.*)$/$1/;
$bsize <=> $asize
@@ -70,8 +72,9 @@ sub bysize($) {
#
# main()
#
-$funcre = qr/^$x* \<(.*)\>:$/;
-while ($line = <STDIN>) {
+my $funcre = qr/^$x* <(.*)>:$/;
+my $func;
+while (my $line = <STDIN>) {
if ($line =~ m/$funcre/) {
$func = $1;
}
@@ -85,7 +88,7 @@ while ($line = <STDIN>) {
$size += 0x80000000;
}
- $line =~ m/^($xs*).*/;
+ next if $line !~ m/^($xs*)/;
my $addr = $1;
$addr =~ s/ /0/g;
$addr = "0x$addr";
@@ -97,12 +100,8 @@ while ($line = <STDIN>) {
$padlen -= 8;
}
next if ($size < 100);
- $stack[@stack] = "$intro$size\n";
+ push @stack, "$intro$size\n";
}
}
-@sortedstack = sort bysize @stack;
-
-foreach $i (@sortedstack) {
- print("$i");
-}
+print sort bysize @stack;