Skip to content

Commit a55ee0c

Browse files
JoePerchestorvalds
authored andcommitted
checkpatch: look for c99 comments in ctx_locate_comment
Some checks look for comments around a specific function like read_barrier_depends. Extend the check to support both c89 and c90 comment styles. c89 /* comment */ or c99 // comment For c99 comments, only look a 3 single lines, the line being scanned, the line above and the line below the line being scanned rather than the patch diff context. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Tested-by: Paul E. McKenney <paulmck@kernel.org> Cc: Marco Elver <elver@google.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Alexander Potapenko <glider@google.com> Cc: Andrey Konovalov <andreyknvl@google.com> Cc: Andy Whitcroft <apw@canonical.com> Cc: Will Deacon <will@kernel.org> Link: http://lkml.kernel.org/r/65cb075435d2f385a53c77571b491b2b09faaf8e.camel@perches.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 7ccf41a commit a55ee0c

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎scripts/checkpatch.pl‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1676,8 +1676,16 @@ sub ctx_statement_level {
16761676
sub ctx_locate_comment {
16771677
my ($first_line, $end_line) = @_;
16781678

1679+
# If c99 comment on the current line, or the line before or after
1680+
my ($current_comment) = ($rawlines[$end_line - 1] =~ m@^\+.*(//.*$)@);
1681+
return $current_comment if (defined $current_comment);
1682+
($current_comment) = ($rawlines[$end_line - 2] =~ m@^[\+ ].*(//.*$)@);
1683+
return $current_comment if (defined $current_comment);
1684+
($current_comment) = ($rawlines[$end_line] =~ m@^[\+ ].*(//.*$)@);
1685+
return $current_comment if (defined $current_comment);
1686+
16791687
# Catch a comment on the end of the line itself.
1680-
my ($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*(?:\\\s*)?$@);
1688+
($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*(?:\\\s*)?$@);
16811689
return $current_comment if (defined $current_comment);
16821690

16831691
# Look through the context and try and figure out if there is a

0 commit comments

Comments
 (0)