Skip to content

Commit 0588060

Browse files
JoePerchestorvalds
authored andcommitted
checkpatch: check networking specific block comment style
In an effort to get fewer checkpatch reviewer corrections, add a networking specific style test for the preferred networking comment style. /* The preferred style for block comments in * drivers/net/... and net/... is like this */ These tests are only used in net/ and drivers/net/ Tested with: $ cat drivers/net/t.c /* foo */ /* * foo */ /* foo */ /* foo * bar */ $ ./scripts/checkpatch.pl -f drivers/net/t.c WARNING: networking block comments don't use an empty /* line, use /* Comment... #4: FILE: net/t.c:4: + +/* WARNING: networking block comments put the trailing */ on a separate line #12: FILE: net/t.c:12: + * bar */ total: 0 errors, 2 warnings, 12 lines checked Signed-off-by: Joe Perches <[email protected]> Cc: "Allan, Bruce W" <[email protected]> Cc: Andy Whitcroft <[email protected]> Cc: David Miller <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 8f26b83 commit 0588060

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

scripts/checkpatch.pl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,6 +1882,20 @@ sub process {
18821882
"No space is necessary after a cast\n" . $hereprev);
18831883
}
18841884

1885+
if ($realfile =~ m@^(drivers/net/|net/)@ &&
1886+
$rawline =~ /^\+[ \t]*\/\*[ \t]*$/ &&
1887+
$prevrawline =~ /^\+[ \t]*$/) {
1888+
WARN("NETWORKING_BLOCK_COMMENT_STYLE",
1889+
"networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);
1890+
}
1891+
1892+
if ($realfile =~ m@^(drivers/net/|net/)@ &&
1893+
$rawline !~ m@^\+[ \t]*(\/\*|\*\/)@ &&
1894+
$rawline =~ m@^\+[ \t]*.+\*\/[ \t]*$@) {
1895+
WARN("NETWORKING_BLOCK_COMMENT_STYLE",
1896+
"networking block comments put the trailing */ on a separate line\n" . $herecurr);
1897+
}
1898+
18851899
# check for spaces at the beginning of a line.
18861900
# Exceptions:
18871901
# 1) within comments

0 commit comments

Comments
 (0)