]> git.puffer.fish Git - mirror/frr.git/commitdiff
tools: checkpatch.sh - Add warning that // style comments don't match 1890/head
authorLou Berger <lberger@labn.net>
Wed, 14 Mar 2018 14:36:27 +0000 (10:36 -0400)
committerLou Berger <lberger@labn.net>
Wed, 14 Mar 2018 14:42:20 +0000 (10:42 -0400)
       recommended (kernel) comment style

Signed-off-by: Lou Berger <lberger@labn.net>
tools/checkpatch.pl

index a952de89474d48061eea3b0bd3769c1c5a2d7cf4..a85d811c96a0559361748d28b1be95b68db0c4e8 100755 (executable)
@@ -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.