checkpatch: handle C99 comments correctly (performance issue)
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> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
463f286485
commit
113f04a836
1 changed files with 13 additions and 0 deletions
|
@ -356,6 +356,13 @@ sub sanitise_line {
|
||||||
$off++;
|
$off++;
|
||||||
next;
|
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.
|
# A \ in a string means ignore the next character.
|
||||||
if (($sanitise_quote eq "'" || $sanitise_quote eq '"') &&
|
if (($sanitise_quote eq "'" || $sanitise_quote eq '"') &&
|
||||||
|
@ -379,6 +386,8 @@ sub sanitise_line {
|
||||||
#print "c<$c> SQ<$sanitise_quote>\n";
|
#print "c<$c> SQ<$sanitise_quote>\n";
|
||||||
if ($off != 0 && $sanitise_quote eq '*/' && $c ne "\t") {
|
if ($off != 0 && $sanitise_quote eq '*/' && $c ne "\t") {
|
||||||
substr($res, $off, 1, $;);
|
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") {
|
} elsif ($off != 0 && $sanitise_quote && $c ne "\t") {
|
||||||
substr($res, $off, 1, 'X');
|
substr($res, $off, 1, 'X');
|
||||||
} else {
|
} else {
|
||||||
|
@ -386,6 +395,10 @@ sub sanitise_line {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($sanitise_quote eq '//') {
|
||||||
|
$sanitise_quote = '';
|
||||||
|
}
|
||||||
|
|
||||||
# The pathname on a #include may be surrounded by '<' and '>'.
|
# The pathname on a #include may be surrounded by '<' and '>'.
|
||||||
if ($res =~ /^.\s*\#\s*include\s+\<(.*)\>/) {
|
if ($res =~ /^.\s*\#\s*include\s+\<(.*)\>/) {
|
||||||
my $clean = 'X' x length($1);
|
my $clean = 'X' x length($1);
|
||||||
|
|
Loading…
Reference in a new issue