Commit 1f2a144f5ab5e836b5ca8f67bd76b759fa947751

Authored by Stephen Hemminger
Committed by Michal Marek
1 parent b59a122584

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>

Showing 1 changed file with 6 additions and 10 deletions Side-by-side Diff

scripts/checkstack.pl
... ... @@ -21,6 +21,8 @@
21 21 #
22 22 # TODO : Port to all architectures (one regex per arch)
23 23  
  24 +use strict;
  25 +
24 26 # check for arch
25 27 #
26 28 # $re is used for two matches:
27 29  
... ... @@ -104,19 +106,11 @@
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 110 # main()
116 111 #
117 112 my $funcre = qr/^$x* <(.*)>:$/;
118   -my $func;
119   -my $file, $lastslash;
  113 +my ($func, $file, $lastslash);
120 114  
121 115 while (my $line = <STDIN>) {
122 116 if ($line =~ m/$funcre/) {
... ... @@ -173,5 +167,6 @@
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;