public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: Cong Wang <amwang@redhat.com>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
	"Luis R. Rodriguez" <lrodriguez@atheros.com>,
	"Sam Ravnborg" <sam@ravnborg.org>,
	"Vegard Nossum" <vegard.nossum@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Robert P. J. Day" <rpjday@crashcourse.ca>,
	"Arnd Bergmann" <arnd@arndb.de>,
	"Arjan van de Ven" <arjan@linux.intel.com>,
	"Hui Zhu" <teawater@gmail.com>,
	"Ozan Ãaglayan" <ozan@pardus.org.tr>,
	"Matthew Wilcox" <willy@linux.intel.com>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Li Hong" <lihong.hi@gmail.com>, "Ingo Molnar" <mingo@elte.hu>,
	"Ralf Baechle" <ralf@linux-mips.org>,
	"Matt Fleming" <matt@console-pimps.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] scripts: improve checkstack
Date: Fri, 19 Feb 2010 22:25:54 -0800	[thread overview]
Message-ID: <20100219222554.17d4bae6@nehalam> (raw)
In-Reply-To: <4B7F5128.70501@redhat.com>

Turn on strict checking, and get rid of annoying use of prototype.
Fix syntax error in declaration

Use efficient sort algorithm by using schwartzian transform.
  http://en.wikipedia.org/wiki/Schwartzian_transform

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

--- a/scripts/checkstack.pl	2010-02-19 21:57:57.609178016 -0800
+++ b/scripts/checkstack.pl	2010-02-19 22:23:16.038241212 -0800
@@ -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 = <STDIN>) {
 	if ($line =~ m/$funcre/) {
@@ -173,4 +167,7 @@ while (my $line = <STDIN>) {
 	}
 }
 
-print sort bysize @stack;
+# Use Schwartzian transform to sort by last field (size)
+print map { $_->[0] }
+      sort { $b->[1] <=> $a->[1] }
+      map { [$_, /:\t*(\d+)$/] } @stack;

  reply	other threads:[~2010-02-20  6:26 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20100219175217.385580142@vyatta.com>
     [not found] ` <20100219175429.756761745@vyatta.com>
2010-02-19 18:19   ` [PATCH 03/10] Subject checkversion: perl cleanup Ralf Baechle
2010-02-20  3:07   ` Cong Wang
     [not found] ` <20100219175429.611463369@vyatta.com>
2010-02-20  3:04   ` [PATCH 01/10] checkstack: fix perlcritic warnings Cong Wang
2010-02-20  6:25     ` Stephen Hemminger [this message]
2010-02-20  7:35       ` [PATCH] scripts: improve checkstack Cong Wang
2010-02-22 16:43         ` Stephen Hemminger
2010-02-22 16:58           ` Arjan van de Ven
2010-02-22 17:59             ` Steven Rostedt
2010-02-22 18:22               ` Stephen Hemminger
     [not found] ` <20100219175429.683903905@vyatta.com>
2010-02-20  3:05   ` [PATCH 02/10] checkincludes: fix perlcritic warnings Cong Wang
2010-02-20  6:05     ` Stephen Hemminger
2010-02-20  7:30       ` Cong Wang
     [not found] ` <20100219175429.826376846@vyatta.com>
2010-02-20  3:13   ` [PATCH 04/10] namespace: " Cong Wang
2010-02-20  6:27     ` Stephen Hemminger
2010-02-20  7:35       ` Cong Wang
2010-02-20  8:26   ` Hui Zhu
2010-02-22 16:41     ` Stephen Hemminger
     [not found] ` <20100219175429.897113117@vyatta.com>
2010-02-20  3:14   ` [PATCH 05/10] profile2linkerlist: fix perl warnings Cong Wang
     [not found] ` <20100219175429.969182010@vyatta.com>
2010-02-20  3:23   ` [PATCH 06/10] export_report: " Cong Wang
     [not found] ` <20100219175430.039442417@vyatta.com>
2010-02-20  3:26   ` [PATCH 07/10] headers_check: " Cong Wang
     [not found] ` <20100219175430.107836066@vyatta.com>
2010-02-20  3:29   ` [PATCH 08/10] headers_install: use local file handles Cong Wang
     [not found] ` <20100219175430.177001887@vyatta.com>
2010-02-20  3:31   ` [PATCH 09/10] markup_oops: fix perlcritic warnings Cong Wang
     [not found] ` <20100219175430.246644080@vyatta.com>
2010-02-20  3:33   ` [PATCH 10/10] headerdep: perlcritic warning Cong Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100219222554.17d4bae6@nehalam \
    --to=shemminger@vyatta.com \
    --cc=akpm@linux-foundation.org \
    --cc=amwang@redhat.com \
    --cc=arjan@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=lihong.hi@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrodriguez@atheros.com \
    --cc=matt@console-pimps.org \
    --cc=mingo@elte.hu \
    --cc=ozan@pardus.org.tr \
    --cc=ralf@linux-mips.org \
    --cc=rostedt@goodmis.org \
    --cc=rpjday@crashcourse.ca \
    --cc=sam@ravnborg.org \
    --cc=teawater@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=vegard.nossum@gmail.com \
    --cc=willy@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox