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,6 +3607,7 @@ sub process {
# no C99 // comments # no C99 // comments
if ($line =~ m{//}) { if ($line =~ m{//}) {
if (!$allow_c99_comments) {
if(ERROR("C99_COMMENTS", if(ERROR("C99_COMMENTS",
"do not use C99 // comments\n" . $herecurr) && "do not use C99 // comments\n" . $herecurr) &&
$fix) { $fix) {
@ -3621,6 +3617,10 @@ sub process {
$fixed[$fixlinenr] =~ s@\/\/(.*)$@/\* $comment \*/@; $fixed[$fixlinenr] =~ s@\/\/(.*)$@/\* $comment \*/@;
} }
} }
} else {
WARN("C99_COMMENTS",
"C99 // comments do not match recommendation\n" . $herecurr);
}
} }
# Remove C99 comments. # Remove C99 comments.
$line =~ s@//.*@@; $line =~ s@//.*@@;