Skip to content

Commit

Permalink
checkpatch: check networking specific block comment style
Browse files Browse the repository at this point in the history
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...
imx6-dongle#4: FILE: net/t.c:4:
+
+/*

WARNING: networking block comments put the trailing */ on a separate line
imx6-dongle#12: FILE: net/t.c:12:
+ * bar */

total: 0 errors, 2 warnings, 12 lines checked

Signed-off-by: Joe Perches <joe@perches.com>
Cc: "Allan, Bruce W" <bruce.w.allan@intel.com>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
JoePerches authored and torvalds committed Oct 5, 2012
1 parent 8f26b83 commit 0588060
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1882,6 +1882,20 @@ sub process {
"No space is necessary after a cast\n" . $hereprev);
}

if ($realfile =~ m@^(drivers/net/|net/)@ &&
$rawline =~ /^\+[ \t]*\/\*[ \t]*$/ &&
$prevrawline =~ /^\+[ \t]*$/) {
WARN("NETWORKING_BLOCK_COMMENT_STYLE",
"networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);
}

if ($realfile =~ m@^(drivers/net/|net/)@ &&
$rawline !~ m@^\+[ \t]*(\/\*|\*\/)@ &&
$rawline =~ m@^\+[ \t]*.+\*\/[ \t]*$@) {
WARN("NETWORKING_BLOCK_COMMENT_STYLE",
"networking block comments put the trailing */ on a separate line\n" . $herecurr);
}

# check for spaces at the beginning of a line.
# Exceptions:
# 1) within comments
Expand Down

0 comments on commit 0588060

Please sign in to comment.