aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2020-05-04 07:22:49 -0400
committerMichael S. Tsirkin <mst@redhat.com>2020-05-04 10:25:02 -0400
commite625ba2a413f2bfdbb71c71008b627fede20fcbb (patch)
treeb602567e88f5ec10325fa54abf72781dcad26d58 /scripts
parent0ac2e63575b5af918e333cc687bbd8e1ab7bb6fe (diff)
checkpatch: fix acpi check with multiple file name
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>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl22
1 files 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 '' &&