lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 10 Apr 2013 10:59:38 +0200
From:	Matthijs Kooijman <matthijs@...in.nl>
To:	Joe Perches <joe@...ches.com>
Cc:	Andy Whitcroft <apw@...onical.com>,
	Paul Zimmerman <Paul.Zimmerman@...opsys.com>,
	linux-kernel@...r.kernel.org
Subject: [PATCH v3] checkpatch: check block comments outside of net

There was some code checking block comments in net/ and drivers/net/,
but nothing for regular comments.

The end of a block comment is the same as inside net, so that check can
just be generalized.

The start of block comment must not have any comment after the leading
/*, which requires a new check.

Tested with:

$ cat test.c
/* foo */

/*
 * foo
 */

/* foo
 */

/* foo
 * bar */

/**
 * foo
 * bar
 */

/****************************
 * some long block comment
 ****************************/

struct foo {
        int bar;        /* another test */
};

$ ./scripts/checkpatch.pl --strict -f test.c
CHECK: block comments put the leading /* on a separate line
+
+/* foo

CHECK: block comments put the leading /* on a separate line
+
+/* foo

CHECK: block comments put the trailing */ on a separate line
+ * bar */

total: 0 errors, 0 warnings, 3 checks, 25 lines checked

test.c has style problems, please review.

If any of these errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

Signed-off-by: Matthijs Kooijman <matthijs@...in.nl>

---

v2: change the error message for consistency
    add a comment
v3: allow /*{2,} as well
    convert to CHK

I've also allowed /******************** since that seems to be used in
a lot of places as well.
---
 scripts/checkpatch.pl | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b28cc38..64021da 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1884,13 +1884,21 @@ sub process {
 			     "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);
 		}
 
-		if ($realfile =~ m@^(drivers/net/|net/)@ &&
-		    $rawline !~ m@^\+[ \t]*\*/[ \t]*$@ &&	#trailing */
+		if ($realfile !~ m@^(drivers/net/|net/)@ &&
+		    $rawline !~ m@^\+.*/\*.*\*/[ \t]*$@ &&	#inline /*...*/
+		    $rawline !~ /^\+[ \t]*\/\*\*?[ \t]*$/ &&	#blank /* or /**
+		    $rawline =~ /^\+[ \t]*\/\*.+$/ &&		#non blank /*
+		    $prevrawline =~ /^\+[ \t]*$/) {
+			CHK("BLOCK_COMMENT_STYLE",
+			     "block comments put the leading /* on a separate line\n" . $hereprev);
+		}
+
+		if ($rawline !~ m@^\+[ \t]*\*/[ \t]*$@ &&	#trailing */
 		    $rawline !~ m@^\+.*/\*.*\*/[ \t]*$@ &&	#inline /*...*/
 		    $rawline !~ m@^\+.*\*{2,}/[ \t]*$@ &&	#trailing **/
 		    $rawline =~ m@^\+[ \t]*.+\*\/[ \t]*$@) {	#non blank */
-			WARN("NETWORKING_BLOCK_COMMENT_STYLE",
-			     "networking block comments put the trailing */ on a separate line\n" . $herecurr);
+			CHK("BLOCK_COMMENT_STYLE",
+			     "block comments put the trailing */ on a separate line\n" . $herecurr);
 		}
 
 # check for spaces at the beginning of a line.
-- 
1.8.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ