From nobody Sun Feb 8 19:54:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1537346320357110.46179009777416; Wed, 19 Sep 2018 01:38:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7BE4AC059B86; Wed, 19 Sep 2018 08:38:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 47B7C80683; Wed, 19 Sep 2018 08:38:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 01F69181A369; Wed, 19 Sep 2018 08:38:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8J8cVYm006633 for ; Wed, 19 Sep 2018 04:38:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 599901001F5E; Wed, 19 Sep 2018 08:38:31 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4C2A81092002 for ; Wed, 19 Sep 2018 08:38:28 +0000 (UTC) Received: from m97135.mail.qiye.163.com (m97135.mail.qiye.163.com [220.181.97.135]) by mx1.redhat.com (Postfix) with ESMTP id 696BE7F3F1 for ; Wed, 19 Sep 2018 08:38:26 +0000 (UTC) Received: from localhost.localdomain (unknown [58.56.27.130]) by smtp1 (Coremail) with SMTP id h+CowACH6K8AC6Jb9vM3Ag--.63S4; Wed, 19 Sep 2018 16:38:25 +0800 (CST) From: Shi Lei To: libvir-list@redhat.com Date: Wed, 19 Sep 2018 16:38:15 +0800 Message-Id: <20180919083819.11042-3-shi_lei@massclouds.com> In-Reply-To: <20180919083819.11042-1-shi_lei@massclouds.com> References: <20180919083819.11042-1-shi_lei@massclouds.com> X-CM-TRANSID: h+CowACH6K8AC6Jb9vM3Ag--.63S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7uFWrWF1fJrWfWw15Kry7trb_yoW5JFWxpa ySyrWfuwnYgrn7XasrAa48Xr93WrWkCrZ8Wr47Xa4kJF98CF1vqrWjgF18tryj9rs7Aw40 ga9YqF47Cr1DZrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pRX6p9UUUUU= X-Originating-IP: [58.56.27.130] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbiewHGT1rpNinaBQAAsA X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 214 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 19 Sep 2018 08:38:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 19 Sep 2018 08:38:27 +0000 (UTC) for IP:'220.181.97.135' DOMAIN:'m97135.mail.qiye.163.com' HELO:'m97135.mail.qiye.163.com' FROM:'shi_lei@massclouds.com' RCPT:'' X-RedHat-Spam-Score: -0.01 (RCVD_IN_DNSWL_NONE) 220.181.97.135 m97135.mail.qiye.163.com 220.181.97.135 m97135.mail.qiye.163.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/6] build-aux:check-spacing: Add wrapper function of CheckFunctionBody X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 19 Sep 2018 08:38:39 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch adds CheckFunctionBody to simplifies check-spacing. Signed-off-by: Shi Lei --- build-aux/check-spacing.pl | 61 +++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/build-aux/check-spacing.pl b/build-aux/check-spacing.pl index da9a58b..c5d5a69 100755 --- a/build-aux/check-spacing.pl +++ b/build-aux/check-spacing.pl @@ -23,6 +23,45 @@ use strict; use warnings; =20 +# +# CheckFunctionBody: +# $_[0]: $data(in) +# $_[1]: $location(in), which format is file-path:line-num:line-code +# $_[2]: $fn_linenum(inout), maintains start line-num of function body +# Returns 0 in case of success or 1 on failure +# +# Check incorrect indentation and blank first line in function body. +# For efficiency, it only checks the first line of function body. +# But it's enough for most cases. +# (It could be better that we use *state* to declare @fn_linenum and +# move it into this subroutine. But *state* requires version >=3D v5.10.) +# +sub CheckFunctionBody { + my $ret =3D 0; + my ($data, $location, $fn_linenum) =3D @_; + + # Check first line of function block + if ($$fn_linenum) { + if ($$data =3D~ /^\s*$/) { + print "Blank line before content in function body:\n$$location= "; + $ret =3D 1; + } elsif ($$data !~ /^[ ]{4}\S/) { + unless ($$data =3D~ /^[ ]\w+:$/ || $$data =3D~ /^}/) { + print "Incorrect indentation in function body:\n$$location= "; + $ret =3D 1; + } + } + $$fn_linenum =3D 0; + } + + # Detect start of function block + if ($$data =3D~ /^{$/) { + $$fn_linenum =3D $.; + } + + return $ret; +} + my $ret =3D 0; my $incomment =3D 0; =20 @@ -37,6 +76,7 @@ foreach my $file (@ARGV) { =20 while (defined (my $line =3D )) { my $data =3D $line; + my $location =3D "$file:$.:\n$line"; # For temporary modifications my $tmpdata; =20 @@ -51,26 +91,7 @@ foreach my $file (@ARGV) { =20 next if $data =3D~ /^#/; =20 - # Detect start of function block - if ($data =3D~ /^{$/) { - $fn_linenum =3D $.; - } - - # Handle first line of function block - if ($fn_linenum && $fn_linenum !=3D $.) { - if ($data =3D~ /^\s*$/) { - print "Blank line before content in function body:\n"; - print "$file:$.:\n$line"; - $ret =3D 1; - } elsif ($data !~ /^[ ]{4}\S/) { - unless ($data =3D~ /^[ ]\w+:$/ || $data =3D~ /^}/) { - print "Incorrect indentation in function body:\n"; - print "$file:$.:\n$line"; - $ret =3D 1; - } - } - $fn_linenum =3D 0; - } + $ret =3D 1 if CheckFunctionBody(\$data, \$location, \$fn_linenum); =20 # Kill contents of multi-line comments # and detect end of multi-line comments --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list