From patchwork Thu Dec 13 17:55:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wainer dos Santos Moschetta X-Patchwork-Id: 10729395 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1DAE11759 for ; Thu, 13 Dec 2018 17:57:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11DA02B0EC for ; Thu, 13 Dec 2018 17:57:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 05E722C81C; Thu, 13 Dec 2018 17:57:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 59CDA2BBD8 for ; Thu, 13 Dec 2018 17:57:37 +0000 (UTC) Received: from localhost ([::1]:54034 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXVEu-0000FO-Jk for patchwork-qemu-devel@patchwork.kernel.org; Thu, 13 Dec 2018 12:57:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXVE0-000822-BQ for qemu-devel@nongnu.org; Thu, 13 Dec 2018 12:56:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXVDx-00053G-36 for qemu-devel@nongnu.org; Thu, 13 Dec 2018 12:56:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37142) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gXVDw-0004zF-Ro for qemu-devel@nongnu.org; Thu, 13 Dec 2018 12:56:36 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 37ED23082127 for ; Thu, 13 Dec 2018 17:56:35 +0000 (UTC) Received: from virtlab501.virt.lab.eng.bos.redhat.com (virtlab501.virt.lab.eng.bos.redhat.com [10.19.152.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01AA0261C7; Thu, 13 Dec 2018 17:56:23 +0000 (UTC) From: Wainer dos Santos Moschetta To: qemu-devel@nongnu.org Date: Thu, 13 Dec 2018 12:55:52 -0500 Message-Id: <20181213175552.14857-2-wainersm@redhat.com> In-Reply-To: <20181213175552.14857-1-wainersm@redhat.com> References: <20181213175552.14857-1-wainersm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 13 Dec 2018 17:56:35 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/1] checkpatch: check for malformed comment block. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, thuth@redhat.com, ehabkost@redhat.com, stefanha@redhat.com, Wainer dos Santos Moschetta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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" .