tools: checkpatch.sh - Add warning that // style comments don't match

recommended (kernel) comment style

Signed-off-by: Lou Berger <lberger@labn.net>
This commit is contained in:
Lou Berger 2018-03-14 10:36:27 -04:00
parent 7a7a480dfe
commit f1beb87ed1

View File

@ -1249,11 +1249,6 @@ sub sanitise_line {
$res =~ s@(\#\s*(?:error|warning)\s+).*@$1$clean@; $res =~ s@(\#\s*(?:error|warning)\s+).*@$1$clean@;
} }
if ($allow_c99_comments && $res =~ m@(//.*$)@) {
my $match = $1;
$res =~ s/\Q$match\E/"$;" x length($match)/e;
}
return $res; return $res;
} }
@ -3612,14 +3607,19 @@ sub process {
# no C99 // comments # no C99 // comments
if ($line =~ m{//}) { if ($line =~ m{//}) {
if (ERROR("C99_COMMENTS", if (!$allow_c99_comments) {
"do not use C99 // comments\n" . $herecurr) && if(ERROR("C99_COMMENTS",
$fix) { "do not use C99 // comments\n" . $herecurr) &&
my $line = $fixed[$fixlinenr]; $fix) {
if ($line =~ /\/\/(.*)$/) { my $line = $fixed[$fixlinenr];
my $comment = trim($1); if ($line =~ /\/\/(.*)$/) {
$fixed[$fixlinenr] =~ s@\/\/(.*)$@/\* $comment \*/@; my $comment = trim($1);
$fixed[$fixlinenr] =~ s@\/\/(.*)$@/\* $comment \*/@;
}
} }
} else {
WARN("C99_COMMENTS",
"C99 // comments do not match recommendation\n" . $herecurr);
} }
} }
# Remove C99 comments. # Remove C99 comments.