From patchwork Wed Dec 21 18:01:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 9483589 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7A604600C1 for ; Wed, 21 Dec 2016 18:02:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72CFB28410 for ; Wed, 21 Dec 2016 18:02:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65C5528473; Wed, 21 Dec 2016 18:02:35 +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=-6.9 required=2.0 tests=BAYES_00,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 D7C9828410 for ; Wed, 21 Dec 2016 18:02:34 +0000 (UTC) Received: from localhost ([::1]:58367 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cJlDl-0005Is-V9 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Dec 2016 13:02:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cJlDN-0005Ad-Dr for qemu-devel@nongnu.org; Wed, 21 Dec 2016 13:02:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cJlDH-0008OJ-Og for qemu-devel@nongnu.org; Wed, 21 Dec 2016 13:02:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33260) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cJlDC-0008Mq-UJ; Wed, 21 Dec 2016 13:01:59 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BE2ED285A5; Wed, 21 Dec 2016 18:01:57 +0000 (UTC) Received: from localhost (ovpn-116-3.gru2.redhat.com [10.97.116.3]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uBLI1uJv031682; Wed, 21 Dec 2016 13:01:57 -0500 Date: Wed, 21 Dec 2016 16:01:55 -0200 From: Eduardo Habkost To: Paolo Bonzini Message-ID: <20161221180155.GI3808@thinpad.lan.raisama.net> References: <20161201170624.26496-1-lersek@redhat.com> <148227487620.73.10055858460424473693@790289a7ca88> <20161221152226.GH3808@thinpad.lan.raisama.net> <70b42a58-381d-7011-7eef-2120af178f91@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <70b42a58-381d-7011-7eef-2120af178f91@redhat.com> X-Fnord: you can see the fnord User-Agent: Mutt/1.7.1 (2016-10-04) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 21 Dec 2016 18:01:57 +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: Re: [Qemu-devel] checkpatch.pl false positive (was Re: [PATCH v4 0/7] q35: add negotiable broadcast SMI) 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: peter.maydell@linaro.org, famz@redhat.com, mst@redhat.com, somlo@cmu.edu, qemu-devel@nongnu.org, Markus Armbruster , michael@walle.cc, qemu-arm@nongnu.org, kraxel@redhat.com, zhaoshenglong@huawei.com, imammedo@redhat.com, lersek@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Wed, Dec 21, 2016 at 06:47:01PM +0100, Paolo Bonzini wrote: > > > On 21/12/2016 16:22, Eduardo Habkost wrote: > > On Tue, Dec 20, 2016 at 03:01:17PM -0800, no-reply@patchew.org wrote: > > [...] > >> Checking PATCH 4/7: hw/i386/pc: introduce 2.9 machine types with 0x20 fw_cfg file slots... > >> ERROR: Macros with multiple statements should be enclosed in a do - while loop > >> #126: FILE: include/hw/compat.h:4: > >> +#define HW_COMPAT_2_8 \ > >> + {\ > >> + .driver = "fw_cfg_mem",\ > >> + .property = "file_slots",\ > >> + .value = stringify(0x10),\ > >> + },{\ > >> + .driver = "fw_cfg_io",\ > >> + .property = "file_slots",\ > >> + .value = stringify(0x10),\ > >> + }, > >> > >> total: 1 errors, 0 warnings, 119 lines checked > >> > >> Your patch has style problems, please review. If any of these errors > >> are false positives report them to the maintainer, see > >> CHECKPATCH in MAINTAINERS. > > > > It is a false positive, but how exactly can we fix it? Should it > > become a warning instead of an error? > > It should already be treated as an exception: > > my $exceptions = qr{ > $Declare| > module_param_named| > MODULE_PARAM_DESC| > DECLARE_PER_CPU| > DEFINE_PER_CPU| > __typeof__\(| > union| > struct| > \.$Ident\s*=\s*| # <---- see here > ^\"|\"$ > }x; > #print "REST<$rest> dstat<$dstat> ctx<$ctx>\n"; > if ($rest ne '' && $rest ne ',') { > if ($rest !~ /while\s*\(/ && > $dstat !~ /$exceptions/) > { > ERROR("Macros with multiple statements should be enclosed in a do - while loop\n" . "$here\n$ctx\n"); > } > > > so I guess the first step is debugging it. :) The following code replaces the whole "{ .driver = ... }" block with "1": # Flatten any parentheses and braces while ($dstat =~ s/\([^\(\)]*\)/1/ || $dstat =~ s/\{[^\{\}]*\}/1/ || $dstat =~ s/\[[^\{\}]*\]/1/) { } The following change fixes the bug, but I don't know if it has unwanted side-effects: diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index f084542..0aab3ac 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2200,6 +2200,10 @@ sub process { $dstat =~ s/^\s*//s; $dstat =~ s/\s*$//s; + # remove braces that cover the whole block, if any: + $dstat =~ s/^\{//; + $dstat =~ s/\}$//; + # Flatten any parentheses and braces while ($dstat =~ s/\([^\(\)]*\)/1/ || $dstat =~ s/\{[^\{\}]*\}/1/ ||