qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PULL 12/29] checkpatch: fix acpi check with multiple file name
Date: Mon, 4 May 2020 10:29:41 -0400	[thread overview]
Message-ID: <20200504142814.157589-13-mst@redhat.com> (raw)
In-Reply-To: <20200504142814.157589-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



  parent reply	other threads:[~2020-05-04 14:38 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-04 14:29 [PULL 00/29] virtio,acpi,pci,pc: backlog from pre-5.0 Michael S. Tsirkin
2020-05-04 14:29 ` [PULL 01/29] hw/pci/pcie: Forbid hot-plug if it's disabled on the slot Michael S. Tsirkin
2020-05-04 14:29 ` [PULL 02/29] hw/pci/pcie: Replace PCI_DEVICE() casts with existing variable Michael S. Tsirkin
2020-05-04 14:29 ` [PULL 03/29] move 'typedef Aml' to qemu/types.h Michael S. Tsirkin
2020-05-04 14:29 ` [PULL 04/29] acpi: add aml builder stubs Michael S. Tsirkin
2020-05-04 14:29 ` [PULL 05/29] qtest: allow DSDT acpi table changes Michael S. Tsirkin
2020-05-04 14:29 ` [PULL 06/29] acpi: drop pointless _STA method Michael S. Tsirkin
2020-05-04 14:29 ` [PULL 07/29] acpi: add ISADeviceClass->build_aml() Michael S. Tsirkin
2020-05-04 14:29 ` [PULL 08/29] rtc: add RTC_ISA_BASE Michael S. Tsirkin
2020-05-04 14:29 ` [PULL 09/29] virtio-vga: fix virtio-vga bar ordering Michael S. Tsirkin
2020-05-04 14:29 ` [PULL 10/29] virtio-pci: update virtio pci bar layout documentation Michael S. Tsirkin
2020-05-04 14:29 ` [PULL 11/29] vhost-user-blk: fix invalid memory access Michael S. Tsirkin
2020-05-04 14:29 ` Michael S. Tsirkin [this message]
2020-05-04 14:29 ` [PULL 13/29] checkpatch: ignore allowed diff list Michael S. Tsirkin
2020-05-04 14:29 ` [PULL 14/29] acpi: DSDT without _STA Michael S. Tsirkin
2020-05-04 14:29 ` [PULL 15/29] hw/acpi/nvdimm: Fix for NVDIMM incorrect DSM output buffer length Michael S. Tsirkin
2020-05-04 14:29 ` [PULL 16/29] nvdimm: Use configurable ACPI IO base and size Michael S. Tsirkin
2020-05-04 14:29 ` [PULL 17/29] hw/arm/virt: Add nvdimm hot-plug infrastructure Michael S. Tsirkin
2020-05-04 14:29 ` [PULL 18/29] hw/arm/virt: Add nvdimm hotplug support Michael S. Tsirkin
2020-05-04 14:29 ` [PULL 19/29] tests: Update ACPI tables list for upcoming arm/virt test changes Michael S. Tsirkin
2020-05-04 14:30 ` [PULL 20/29] bios-tables-test: test pc-dimm and nvdimm coldplug for arm/virt Michael S. Tsirkin
2020-05-04 14:30 ` [PULL 21/29] tests/acpi: add expected tables for bios-tables-test Michael S. Tsirkin
2020-05-04 14:30 ` [PULL 22/29] Refactor vhost_user_set_mem_table functions Michael S. Tsirkin
2020-05-04 14:30 ` [PULL 23/29] acpi: unit-test: Ignore diff in WAET ACPI table Michael S. Tsirkin
2020-05-04 14:30 ` [PULL 24/29] acpi: Add Windows ACPI Emulated Device Table (WAET) Michael S. Tsirkin
2020-05-04 14:30 ` [PULL 25/29] acpi: unit-test: Update WAET ACPI Table expected binaries Michael S. Tsirkin
2020-05-04 14:30 ` [PULL 26/29] hw/i386/pc: Create 'vmport' device in place Michael S. Tsirkin
2020-05-04 14:30 ` [PULL 27/29] hw/i386/vmport: Remove unused 'hw/input/i8042.h' include Michael S. Tsirkin
2020-05-04 14:30 ` [PULL 28/29] hw/i386: Add 'vmport.h' local header Michael S. Tsirkin
2020-05-04 14:30 ` [PULL 29/29] hw/i386: Make vmmouse helpers static Michael S. Tsirkin
2020-05-04 19:35 ` [PULL 00/29] virtio,acpi,pci,pc: backlog from pre-5.0 Peter Maydell

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=20200504142814.157589-13-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --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).