diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2010-02-22 18:17:09 -0500 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2010-03-07 15:19:09 -0500 |
commit | 1f2a144f5ab5e836b5ca8f67bd76b759fa947751 (patch) | |
tree | d7fdc51eed976f4fa005e6ebcf83538b8436900a /scripts/checkstack.pl | |
parent | b59a12258460b3d019918719b1bd2563cf37ad9a (diff) |
scripts: improve checkstack
Cleanup checkstack script:
* Turn on strict checking
* Fix resulting error message because the declaration syntax
was incorrect.
* Remove incorrect and misleading use of prototype
- prototype not required for this type of sort function
because $a and $b are being used in this contex
- if prototype was being used it should be for both arguments
* Use closure for sort function
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Arjan van de Ven <arjan@infradead.org>
Cc: Cong Wang <amwang@redhat.com>
Cc: Michal Marek <mmarek@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts/checkstack.pl')
-rwxr-xr-x | scripts/checkstack.pl | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl index 14ee68e991dd..1afff6658a7d 100755 --- a/scripts/checkstack.pl +++ b/scripts/checkstack.pl | |||
@@ -21,6 +21,8 @@ | |||
21 | # | 21 | # |
22 | # TODO : Port to all architectures (one regex per arch) | 22 | # TODO : Port to all architectures (one regex per arch) |
23 | 23 | ||
24 | use strict; | ||
25 | |||
24 | # check for arch | 26 | # check for arch |
25 | # | 27 | # |
26 | # $re is used for two matches: | 28 | # $re is used for two matches: |
@@ -104,19 +106,11 @@ my (@stack, $re, $dre, $x, $xs); | |||
104 | } | 106 | } |
105 | } | 107 | } |
106 | 108 | ||
107 | sub bysize($) { | ||
108 | my ($asize, $bsize); | ||
109 | ($asize = $a) =~ s/.*: *(.*)$/$1/; | ||
110 | ($bsize = $b) =~ s/.*: *(.*)$/$1/; | ||
111 | $bsize <=> $asize | ||
112 | } | ||
113 | |||
114 | # | 109 | # |
115 | # main() | 110 | # main() |
116 | # | 111 | # |
117 | my $funcre = qr/^$x* <(.*)>:$/; | 112 | my $funcre = qr/^$x* <(.*)>:$/; |
118 | my $func; | 113 | my ($func, $file, $lastslash); |
119 | my $file, $lastslash; | ||
120 | 114 | ||
121 | while (my $line = <STDIN>) { | 115 | while (my $line = <STDIN>) { |
122 | if ($line =~ m/$funcre/) { | 116 | if ($line =~ m/$funcre/) { |
@@ -173,4 +167,6 @@ while (my $line = <STDIN>) { | |||
173 | } | 167 | } |
174 | } | 168 | } |
175 | 169 | ||
176 | print sort bysize @stack; | 170 | # Sort output by size (last field) |
171 | print sort { ($b =~ /:\t*(\d+)$/)[0] <=> ($a =~ /:\t*(\d+)$/)[0] } @stack; | ||
172 | |||