aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2015-09-09 18:37:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-09-10 16:29:01 -0400
commit86406b1cb7ac4fa5e7691eae5f2fb10c9af03dc3 (patch)
tree99b418c11806cc4ca0c7622d7ff271e5d96ce4e2 /scripts/checkpatch.pl
parent7d3a9f673e1bdb45f86d15a67e230e4a9b050850 (diff)
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: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl19
1 files changed, 11 insertions, 8 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index ea28336ea2a5..7f309f0789a0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2751,6 +2751,8 @@ sub process {
2751 } 2751 }
2752 } 2752 }
2753 2753
2754# Block comment styles
2755# Networking with an initial /*
2754 if ($realfile =~ m@^(drivers/net/|net/)@ && 2756 if ($realfile =~ m@^(drivers/net/|net/)@ &&
2755 $prevrawline =~ /^\+[ \t]*\/\*[ \t]*$/ && 2757 $prevrawline =~ /^\+[ \t]*\/\*[ \t]*$/ &&
2756 $rawline =~ /^\+[ \t]*\*/ && 2758 $rawline =~ /^\+[ \t]*\*/ &&
@@ -2759,22 +2761,23 @@ sub process {
2759 "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev); 2761 "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);
2760 } 2762 }
2761 2763
2762 if ($realfile =~ m@^(drivers/net/|net/)@ && 2764# Block comments use * on subsequent lines
2763 $prevrawline =~ /^\+[ \t]*\/\*/ && #starting /* 2765 if ($prevline =~ /$;[ \t]*$/ && #ends in comment
2766 $prevrawline =~ /^\+.*?\/\*/ && #starting /*
2764 $prevrawline !~ /\*\/[ \t]*$/ && #no trailing */ 2767 $prevrawline !~ /\*\/[ \t]*$/ && #no trailing */
2765 $rawline =~ /^\+/ && #line is new 2768 $rawline =~ /^\+/ && #line is new
2766 $rawline !~ /^\+[ \t]*\*/) { #no leading * 2769 $rawline !~ /^\+[ \t]*\*/) { #no leading *
2767 WARN("NETWORKING_BLOCK_COMMENT_STYLE", 2770 WARN("BLOCK_COMMENT_STYLE",
2768 "networking block comments start with * on subsequent lines\n" . $hereprev); 2771 "Block comments use * on subsequent lines\n" . $hereprev);
2769 } 2772 }
2770 2773
2771 if ($realfile =~ m@^(drivers/net/|net/)@ && 2774# Block comments use */ on trailing lines
2772 $rawline !~ m@^\+[ \t]*\*/[ \t]*$@ && #trailing */ 2775 if ($rawline !~ m@^\+[ \t]*\*/[ \t]*$@ && #trailing */
2773 $rawline !~ m@^\+.*/\*.*\*/[ \t]*$@ && #inline /*...*/ 2776 $rawline !~ m@^\+.*/\*.*\*/[ \t]*$@ && #inline /*...*/
2774 $rawline !~ m@^\+.*\*{2,}/[ \t]*$@ && #trailing **/ 2777 $rawline !~ m@^\+.*\*{2,}/[ \t]*$@ && #trailing **/
2775 $rawline =~ m@^\+[ \t]*.+\*\/[ \t]*$@) { #non blank */ 2778 $rawline =~ m@^\+[ \t]*.+\*\/[ \t]*$@) { #non blank */
2776 WARN("NETWORKING_BLOCK_COMMENT_STYLE", 2779 WARN("BLOCK_COMMENT_STYLE",
2777 "networking block comments put the trailing */ on a separate line\n" . $herecurr); 2780 "Block comments use a trailing */ on a separate line\n" . $herecurr);
2778 } 2781 }
2779 2782
2780# check for missing blank lines after struct/union declarations 2783# check for missing blank lines after struct/union declarations