Skip to content

Commit 1f2a144

Browse files
Stephen Hemmingermichal42
authored andcommitted
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>
1 parent b59a122 commit 1f2a144

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

scripts/checkstack.pl

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#
2222
# TODO : Port to all architectures (one regex per arch)
2323

24+
use strict;
25+
2426
# check for arch
2527
#
2628
# $re is used for two matches:
@@ -104,19 +106,11 @@
104106
}
105107
}
106108

107-
sub bysize($) {
108-
my ($asize, $bsize);
109-
($asize = $a) =~ s/.*: *(.*)$/$1/;
110-
($bsize = $b) =~ s/.*: *(.*)$/$1/;
111-
$bsize <=> $asize
112-
}
113-
114109
#
115110
# main()
116111
#
117112
my $funcre = qr/^$x* <(.*)>:$/;
118-
my $func;
119-
my $file, $lastslash;
113+
my ($func, $file, $lastslash);
120114

121115
while (my $line = <STDIN>) {
122116
if ($line =~ m/$funcre/) {
@@ -173,4 +167,6 @@ ($)
173167
}
174168
}
175169

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+

0 commit comments

Comments
 (0)