Skip to content

Commit

Permalink
checkpatch: handle C99 comments correctly (performance issue)
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Andy Whitcroft <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
daniel-walker authored and torvalds committed Sep 22, 2009
1 parent 463f286 commit 113f04a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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 '"') &&
Expand All @@ -379,13 +386,19 @@ 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 {
substr($res, $off, 1, $c);
}
}

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);
Expand Down

0 comments on commit 113f04a

Please sign in to comment.