Commit 86406b1c authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds

checkpatch: always check block comment styles

Some of the block comment tests that are used only for networking are
appropriate for all patches.

For example, these styles are not encouraged:

	/*
	 block comment without introductory *
	*/
and
	/*
	 * block comment with line terminating */

Remove the networking specific test and add comments.

There are some infrequent false positives where code is lazily
commented out using /* and */ rather than using #if 0/#endif blocks
like:
	/* case foo:
	case bar: */
	case baz:
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7d3a9f67
...@@ -2751,6 +2751,8 @@ sub process { ...@@ -2751,6 +2751,8 @@ sub process {
} }
} }
# Block comment styles
# Networking with an initial /*
if ($realfile =~ m@^(drivers/net/|net/)@ && if ($realfile =~ m@^(drivers/net/|net/)@ &&
$prevrawline =~ /^\+[ \t]*\/\*[ \t]*$/ && $prevrawline =~ /^\+[ \t]*\/\*[ \t]*$/ &&
$rawline =~ /^\+[ \t]*\*/ && $rawline =~ /^\+[ \t]*\*/ &&
...@@ -2759,22 +2761,23 @@ sub process { ...@@ -2759,22 +2761,23 @@ sub process {
"networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev); "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);
} }
if ($realfile =~ m@^(drivers/net/|net/)@ && # Block comments use * on subsequent lines
$prevrawline =~ /^\+[ \t]*\/\*/ && #starting /* if ($prevline =~ /$;[ \t]*$/ && #ends in comment
$prevrawline =~ /^\+.*?\/\*/ && #starting /*
$prevrawline !~ /\*\/[ \t]*$/ && #no trailing */ $prevrawline !~ /\*\/[ \t]*$/ && #no trailing */
$rawline =~ /^\+/ && #line is new $rawline =~ /^\+/ && #line is new
$rawline !~ /^\+[ \t]*\*/) { #no leading * $rawline !~ /^\+[ \t]*\*/) { #no leading *
WARN("NETWORKING_BLOCK_COMMENT_STYLE", WARN("BLOCK_COMMENT_STYLE",
"networking block comments start with * on subsequent lines\n" . $hereprev); "Block comments use * on subsequent lines\n" . $hereprev);
} }
if ($realfile =~ m@^(drivers/net/|net/)@ && # Block comments use */ on trailing lines
$rawline !~ m@^\+[ \t]*\*/[ \t]*$@ && #trailing */ if ($rawline !~ m@^\+[ \t]*\*/[ \t]*$@ && #trailing */
$rawline !~ m@^\+.*/\*.*\*/[ \t]*$@ && #inline /*...*/ $rawline !~ m@^\+.*/\*.*\*/[ \t]*$@ && #inline /*...*/
$rawline !~ m@^\+.*\*{2,}/[ \t]*$@ && #trailing **/ $rawline !~ m@^\+.*\*{2,}/[ \t]*$@ && #trailing **/
$rawline =~ m@^\+[ \t]*.+\*\/[ \t]*$@) { #non blank */ $rawline =~ m@^\+[ \t]*.+\*\/[ \t]*$@) { #non blank */
WARN("NETWORKING_BLOCK_COMMENT_STYLE", WARN("BLOCK_COMMENT_STYLE",
"networking block comments put the trailing */ on a separate line\n" . $herecurr); "Block comments use a trailing */ on a separate line\n" . $herecurr);
} }
# check for missing blank lines after struct/union declarations # check for missing blank lines after struct/union declarations
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment