From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Shameerali Kolothum Thodi"
<shameerali.kolothum.thodi@huawei.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Igor Mammedov" <imammedo@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH 1/2] checkpatch: fix acpi check with multiple file name
Date: Mon, 4 May 2020 07:58:58 -0400 [thread overview]
Message-ID: <20200504115848.34410-2-mst@redhat.com> (raw)
In-Reply-To: <20200504115848.34410-1-mst@redhat.com>
Using global expected/nonexpected values causes
false positives when testing multiple patches in one
checkpatch run: one patch can change expected,
another one non-expected.
Use local variables within process() to fix that.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
scripts/checkpatch.pl | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e658e6546f..c3d08aa99f 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -35,8 +35,6 @@ my $summary_file = 0;
my $root;
my %debug;
my $help = 0;
-my $acpi_testexpected;
-my $acpi_nontestexpected;
sub help {
my ($exitcode) = @_;
@@ -1261,21 +1259,22 @@ sub WARN {
# According to tests/qtest/bios-tables-test.c: do not
# change expected file in the same commit with adding test
sub checkfilename {
- my ($name) = @_;
+ my ($name, $acpi_testexpected, $acpi_nontestexpected) = @_;
+
if ($name =~ m#^tests/data/acpi/# and
# make exception for a shell script that rebuilds the files
not $name =~ m#^\.sh$# or
$name =~ m#^tests/qtest/bios-tables-test-allowed-diff.h$#) {
- $acpi_testexpected = $name;
+ $$acpi_testexpected = $name;
} else {
- $acpi_nontestexpected = $name;
+ $$acpi_nontestexpected = $name;
}
- if (defined $acpi_testexpected and defined $acpi_nontestexpected) {
+ if (defined $$acpi_testexpected and defined $$acpi_nontestexpected) {
ERROR("Do not add expected files together with tests, " .
"follow instructions in " .
"tests/qtest/bios-tables-test.c: both " .
- $acpi_testexpected . " and " .
- $acpi_nontestexpected . " found\n");
+ $$acpi_testexpected . " and " .
+ $$acpi_nontestexpected . " found\n");
}
}
@@ -1325,6 +1324,9 @@ sub process {
my %suppress_whiletrailers;
my %suppress_export;
+ my $acpi_testexpected;
+ my $acpi_nontestexpected;
+
# Pre-scan the patch sanitizing the lines.
sanitise_line_reset();
@@ -1454,11 +1456,11 @@ sub process {
if ($line =~ /^diff --git.*?(\S+)$/) {
$realfile = $1;
$realfile =~ s@^([^/]*)/@@ if (!$file);
- checkfilename($realfile);
+ checkfilename($realfile, \$acpi_testexpected, \$acpi_nontestexpected);
} elsif ($line =~ /^\+\+\+\s+(\S+)/) {
$realfile = $1;
$realfile =~ s@^([^/]*)/@@ if (!$file);
- checkfilename($realfile);
+ checkfilename($realfile, \$acpi_testexpected, \$acpi_nontestexpected);
$p1_prefix = $1;
if (!$file && $tree && $p1_prefix ne '' &&
--
MST
next prev parent reply other threads:[~2020-05-04 12:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-04 11:58 [PATCH 0/2] checkpatch: fix handling of acpi expected files Michael S. Tsirkin
2020-05-04 11:58 ` Michael S. Tsirkin [this message]
2020-05-04 11:59 ` [PATCH 2/2] checkpatch: ignore allowed diff list Michael S. Tsirkin
2020-05-05 5:08 ` [PATCH 0/2] checkpatch: fix handling of acpi expected files no-reply
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=20200504115848.34410-2-mst@redhat.com \
--to=mst@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=imammedo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=stefanha@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).