Skip to content

Commit

Permalink
scripts: improve checkstack
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Arjan van de Ven <[email protected]>
Cc: Cong Wang <[email protected]>
Cc: Michal Marek <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Michal Marek <[email protected]>
  • Loading branch information
Stephen Hemminger authored and michal42 committed Mar 7, 2010
1 parent b59a122 commit 1f2a144
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions scripts/checkstack.pl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#
# TODO : Port to all architectures (one regex per arch)

use strict;

# check for arch
#
# $re is used for two matches:
Expand Down Expand Up @@ -104,19 +106,11 @@
}
}

sub bysize($) {
my ($asize, $bsize);
($asize = $a) =~ s/.*: *(.*)$/$1/;
($bsize = $b) =~ s/.*: *(.*)$/$1/;
$bsize <=> $asize
}

#
# main()
#
my $funcre = qr/^$x* <(.*)>:$/;
my $func;
my $file, $lastslash;
my ($func, $file, $lastslash);

while (my $line = <STDIN>) {
if ($line =~ m/$funcre/) {
Expand Down Expand Up @@ -173,4 +167,6 @@ ($)
}
}

print sort bysize @stack;
# Sort output by size (last field)
print sort { ($b =~ /:\t*(\d+)$/)[0] <=> ($a =~ /:\t*(\d+)$/)[0] } @stack;

0 comments on commit 1f2a144

Please sign in to comment.