From: Andy Whitcroft <apw@canonical.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Ingo Molnar <mingo@elte.hu>,
linux-kernel@vger.kernel.org, Andy Whitcroft <apw@canonical.com>,
Daniel Walker <dwalker@fifo99.com>
Subject: [PATCH 2/7] checkpatch: handle C99 comments correctly (performance issue)
Date: Fri, 21 Aug 2009 22:46:05 +0100 [thread overview]
Message-ID: <1250891170-8599-3-git-send-email-apw@canonical.com> (raw)
In-Reply-To: <1250891170-8599-1-git-send-email-apw@canonical.com>
From: Daniel Walker <dwalker@fifo99.com>
This fixes the sanitation process in checkpatch.pl so that it blocks out
the text after a C99 style comment the same way it does with block style
comments. This prevents the text from getting processed as regular code.
Signed-off-by: Daniel Walker <dwalker@fifo99.com>
Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
scripts/checkpatch.pl | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index fd64816..aa009a3 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -356,6 +356,13 @@ sub sanitise_line {
$off++;
next;
}
+ if ($sanitise_quote eq '' && substr($line, $off, 2) eq '//') {
+ $sanitise_quote = '//';
+
+ substr($res, $off, 2, $sanitise_quote);
+ $off++;
+ next;
+ }
# A \ in a string means ignore the next character.
if (($sanitise_quote eq "'" || $sanitise_quote eq '"') &&
@@ -379,6 +386,8 @@ sub sanitise_line {
#print "c<$c> SQ<$sanitise_quote>\n";
if ($off != 0 && $sanitise_quote eq '*/' && $c ne "\t") {
substr($res, $off, 1, $;);
+ } elsif ($off != 0 && $sanitise_quote eq '//' && $c ne "\t") {
+ substr($res, $off, 1, $;);
} elsif ($off != 0 && $sanitise_quote && $c ne "\t") {
substr($res, $off, 1, 'X');
} else {
@@ -386,6 +395,10 @@ sub sanitise_line {
}
}
+ if ($sanitise_quote eq '//') {
+ $sanitise_quote = '';
+ }
+
# The pathname on a #include may be surrounded by '<' and '>'.
if ($res =~ /^.\s*\#\s*include\s+\<(.*)\>/) {
my $clean = 'X' x length($1);
--
1.6.3.3
next prev parent reply other threads:[~2009-08-21 21:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-21 21:46 [PATCH 0/7] update checkpatch to v0.29 Andy Whitcroft
2009-08-21 21:46 ` [PATCH 1/7] checkpatch: possible types -- else cannot start a type Andy Whitcroft
2009-08-21 21:46 ` Andy Whitcroft [this message]
2009-08-21 21:46 ` [PATCH 3/7] checkpatch: indent checks -- stop when we run out of continuation lines Andy Whitcroft
2009-08-21 21:46 ` [PATCH 4/7] checkpatch: make -f alias --file, add --help, more verbose help message Andy Whitcroft
2009-08-25 11:51 ` Pavel Machek
2009-08-21 21:46 ` [PATCH 5/7] checkpatch: format strings should not have brackets in macros Andy Whitcroft
2009-08-21 21:46 ` [PATCH 6/7] checkpatch: limit sN/uN matches to actual bit sizes Andy Whitcroft
2009-08-21 21:46 ` [PATCH 7/7] checkpatch: version 0.29 Andy Whitcroft
2009-08-21 23:54 ` [PATCH 0/7] update checkpatch to v0.29 Andrew Morton
2009-08-25 7:43 ` checkpatch infinite loop ? Eric Dumazet
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=1250891170-8599-3-git-send-email-apw@canonical.com \
--to=apw@canonical.com \
--cc=akpm@osdl.org \
--cc=dwalker@fifo99.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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
all inboxes | Powered by JetHome®