Commit 1f2a144f authored by Stephen Hemminger's avatar Stephen Hemminger Committed by Michal Marek

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: default avatarStephen 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarMichal Marek <mmarek@suse.cz>
parent b59a1225
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
# #
# TODO : Port to all architectures (one regex per arch) # TODO : Port to all architectures (one regex per arch)
use strict;
# check for arch # check for arch
# #
# $re is used for two matches: # $re is used for two matches:
...@@ -104,19 +106,11 @@ my (@stack, $re, $dre, $x, $xs); ...@@ -104,19 +106,11 @@ my (@stack, $re, $dre, $x, $xs);
} }
} }
sub bysize($) {
my ($asize, $bsize);
($asize = $a) =~ s/.*: *(.*)$/$1/;
($bsize = $b) =~ s/.*: *(.*)$/$1/;
$bsize <=> $asize
}
# #
# main() # main()
# #
my $funcre = qr/^$x* <(.*)>:$/; my $funcre = qr/^$x* <(.*)>:$/;
my $func; my ($func, $file, $lastslash);
my $file, $lastslash;
while (my $line = <STDIN>) { while (my $line = <STDIN>) {
if ($line =~ m/$funcre/) { if ($line =~ m/$funcre/) {
...@@ -173,4 +167,6 @@ while (my $line = <STDIN>) { ...@@ -173,4 +167,6 @@ while (my $line = <STDIN>) {
} }
} }
print sort bysize @stack; # Sort output by size (last field)
print sort { ($b =~ /:\t*(\d+)$/)[0] <=> ($a =~ /:\t*(\d+)$/)[0] } @stack;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment