[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/1] checkpatch: check for malformed comment block.
From: |
Wainer dos Santos Moschetta |
Subject: |
[Qemu-devel] [PATCH 1/1] checkpatch: check for malformed comment block. |
Date: |
Thu, 13 Dec 2018 12:55:52 -0500 |
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 <address@hidden>
---
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
- [Qemu-devel] [PATCH 0/1] checkpatch: checker for comment block, Wainer dos Santos Moschetta, 2018/12/13
- [Qemu-devel] [PATCH 1/1] checkpatch: check for malformed comment block.,
Wainer dos Santos Moschetta <=
- Re: [Qemu-devel] [PATCH 0/1] checkpatch: checker for comment block, Peter Maydell, 2018/12/13
- Re: [Qemu-devel] [PATCH 0/1] checkpatch: checker for comment block, Paolo Bonzini, 2018/12/13
- Re: [Qemu-devel] [PATCH 0/1] checkpatch: checker for comment block, Peter Maydell, 2018/12/13
- Re: [Qemu-devel] [PATCH 0/1] checkpatch: checker for comment block, Paolo Bonzini, 2018/12/13
- Re: [Qemu-devel] [PATCH 0/1] checkpatch: checker for comment block, Markus Armbruster, 2018/12/14
- Re: [Qemu-devel] [PATCH 0/1] checkpatch: checker for comment block, Paolo Bonzini, 2018/12/14
- Re: [Qemu-devel] [PATCH 0/1] checkpatch: checker for comment block, Peter Maydell, 2018/12/14
- Re: [Qemu-devel] [PATCH 0/1] checkpatch: checker for comment block, Markus Armbruster, 2018/12/14
- Re: [Qemu-devel] [PATCH 0/1] checkpatch: checker for comment block, Peter Maydell, 2018/12/14
- Re: [Qemu-devel] [PATCH 0/1] checkpatch: checker for comment block, Markus Armbruster, 2018/12/14