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.
Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all
Unified · Split
| @@ -1676,8 +1676,16 @@ sub ctx_statement_level { · 1675 unmodified lines | ||
| 1676 | 1676 | sub ctx_locate_comment { |
| 1677 | 1677 | my ($first_line, $end_line) = @_; |
| 1678 | 1678 | |
| 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 | + | |
| 1679 | 1687 | # 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*)?$@); | |
| 1681 | 1689 | return $current_comment if (defined $current_comment); |
| 1682 | 1690 | |
| 1683 | 1691 | # Look through the context and try and figure out if there is a |