From: Lou Berger Date: Wed, 14 Mar 2018 14:36:27 +0000 (-0400) Subject: tools: checkpatch.sh - Add warning that // style comments don't match X-Git-Tag: frr-5.0-dev~150^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=f1beb87ed1059cae9aa4e94f61a68f05c9305381;p=matthieu%2Ffrr.git tools: checkpatch.sh - Add warning that // style comments don't match recommended (kernel) comment style Signed-off-by: Lou Berger --- diff --git a/tools/checkpatch.pl b/tools/checkpatch.pl index a952de8947..a85d811c96 100755 --- a/tools/checkpatch.pl +++ b/tools/checkpatch.pl @@ -1249,11 +1249,6 @@ sub sanitise_line { $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; } @@ -3612,14 +3607,19 @@ sub process { # no C99 // comments if ($line =~ m{//}) { - if (ERROR("C99_COMMENTS", - "do not use C99 // comments\n" . $herecurr) && - $fix) { - my $line = $fixed[$fixlinenr]; - if ($line =~ /\/\/(.*)$/) { - my $comment = trim($1); - $fixed[$fixlinenr] =~ s@\/\/(.*)$@/\* $comment \*/@; + if (!$allow_c99_comments) { + if(ERROR("C99_COMMENTS", + "do not use C99 // comments\n" . $herecurr) && + $fix) { + my $line = $fixed[$fixlinenr]; + if ($line =~ /\/\/(.*)$/) { + my $comment = trim($1); + $fixed[$fixlinenr] =~ s@\/\/(.*)$@/\* $comment \*/@; + } } + } else { + WARN("C99_COMMENTS", + "C99 // comments do not match recommendation\n" . $herecurr); } } # Remove C99 comments.