From 1f2a144f5ab5e836b5ca8f67bd76b759fa947751 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 22 Feb 2010 15:17:09 -0800 Subject: 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 Cc: Steven Rostedt Cc: Arjan van de Ven Cc: Cong Wang Cc: Michal Marek Signed-off-by: Andrew Morton Signed-off-by: Michal Marek --- scripts/checkstack.pl | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'scripts/checkstack.pl') diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl index 14ee68e..1afff66 100755 --- a/scripts/checkstack.pl +++ b/scripts/checkstack.pl @@ -21,6 +21,8 @@ # # TODO : Port to all architectures (one regex per arch) +use strict; + # check for arch # # $re is used for two matches: @@ -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() # my $funcre = qr/^$x* <(.*)>:$/; -my $func; -my $file, $lastslash; +my ($func, $file, $lastslash); while (my $line = ) { if ($line =~ m/$funcre/) { @@ -173,4 +167,6 @@ while (my $line = ) { } } -print sort bysize @stack; +# Sort output by size (last field) +print sort { ($b =~ /:\t*(\d+)$/)[0] <=> ($a =~ /:\t*(\d+)$/)[0] } @stack; + -- cgit v1.1