qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Wainer dos Santos Moschetta <wainersm@redhat.com>
To: qemu-devel@nongnu.org
Cc: stefanha@redhat.com, pbonzini@redhat.com, thuth@redhat.com,
	ehabkost@redhat.com,
	Wainer dos Santos Moschetta <wainersm@redhat.com>
Subject: [Qemu-devel] [PATCH 1/1] checkpatch: check for malformed comment block.
Date: Thu, 13 Dec 2018 12:55:52 -0500	[thread overview]
Message-ID: <20181213175552.14857-2-wainersm@redhat.com> (raw)
In-Reply-To: <20181213175552.14857-1-wainersm@redhat.com>

Currently scripts/checkpatch.pl does not check if multiline
comments follow the QEMU's coding sytle.

It is added a check for multiline comments that warns about:
    1. block doesn't begin on its own line.
    2. line in the block doesn't start with asterisk.
    3. block doesn't end on its own line.

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
---
 scripts/checkpatch.pl | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 60f6f89a27..5abb579ed7 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1858,6 +1858,38 @@ sub process {
 		$line =~ s@//.*@@;
 		$opline =~ s@//.*@@;
 
+# check for malformed comment block.
+		if ($rawline =~ m{/\*} && $rawline !~ m{\*\/}) {
+			if ($rawline !~ m{^.\s*/\*+$}) {
+				WARN("comment block should begin on its own" .
+					" line\n" . $herecurr);
+			}
+
+			my $rel_line = 1;
+			my $reported = 0;
+			my $comment_line = '';
+			my $herecurr = '';
+			do {
+				$comment_line = $rawlines[$rel_line + $linenr
+					- 1];
+				$herecurr = "#".($linenr + $rel_line) .
+					": FILE: ".$realfile .
+					":".($realline + $rel_line)."\n" .
+					$comment_line."\n";
+				if (!$reported && $comment_line !~ m{^.\s*\*}) {
+					WARN("line in comment block should" .
+						" start with asterisk\n" .
+						$herecurr);
+					$reported = 1;
+				}
+				$rel_line++;
+			} while ($comment_line && $comment_line !~ m{\*\/});
+
+			if ($comment_line && $comment_line !~ m{^.\s*\*+\/}) {
+				WARN("comment block should end on its own" .
+					" line\n".$herecurr);
+			}
+		}
 # check for global initialisers.
 		if ($line =~ /^.$Type\s*$Ident\s*(?:\s+$Modifier)*\s*=\s*(0|NULL|false)\s*;/) {
 			ERROR("do not initialise globals to 0 or NULL\n" .
-- 
2.19.1

  reply	other threads:[~2018-12-13 17:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-13 17:55 [Qemu-devel] [PATCH 0/1] checkpatch: checker for comment block Wainer dos Santos Moschetta
2018-12-13 17:55 ` Wainer dos Santos Moschetta [this message]
2018-12-13 18:01 ` Peter Maydell
2018-12-13 18:07   ` Paolo Bonzini
2018-12-13 18:21     ` Peter Maydell
2018-12-13 22:23       ` Paolo Bonzini
2018-12-14  6:29         ` Markus Armbruster
2018-12-14  9:32           ` Paolo Bonzini
2018-12-14 11:20           ` Peter Maydell
2018-12-14 12:31             ` Markus Armbruster
2018-12-14 12:57               ` Peter Maydell
2018-12-14 16:11                 ` Markus Armbruster
2018-12-14 12:13   ` Wainer dos Santos Moschetta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181213175552.14857-2-wainersm@redhat.com \
    --to=wainersm@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).