checkpatch: Fix use of uninitialized value
PATCH 1/1 checkpatch: Fix use of uninitialized value
checkfilename() doesn't always set $acpi_testexpected. Fix the following warning:
Use of uninitialized value $acpi_testexpected in string eq at
./scripts/checkpatch.pl line 1529.
--- scripts/checkpatch.pl | 1 + 1 file changed, 1 insertion(+)
scripts/checkpatch.pl +1 -0
@@ -1532,6 +1532,7 @@ sub process { ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ && (defined($1) || defined($2)))) && !(($realfile ne '') && + defined($acpi_testexpected) && ($realfile eq $acpi_testexpected))) { $reported_maintainer_file = 1; WARN("added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr);
How about initializing them explicitly as follows?
($realfile ne '') prevents the case realfile eq '' && acpi_testexpted eq ''. Anyway your patch also should fix it. So
scripts/checkpatch.pl +2 -2
@@ -1325,8 +1325,8 @@ sub process { my %suppress_whiletrailers; my %suppress_export; - my $acpi_testexpected; - my $acpi_nontestexpected; + my $acpi_testexpected = ''; + my $acpi_nontestexpected = ''; # Pre-scan the patch sanitizing the lines.
Quoted 28 lines · Greg Kurz
checkfilename()doesn't always set $acpi_testexpected. Fix the following warning:Use of uninitialized value $acpi_testexpected in string eq at
./scripts/checkpatch.plline 1529.Fixes d2f1af0e4120 ("checkpatch: don't emit warning on newly created acpi data files")Signed-off-by Greg Kurz <[email protected]>--- scripts/checkpatch.pl | 1 + 1 file changed, 1 insertion(+)scripts/checkpatch.pl +1
-0@@ -1532,6 +1532,7 @@ sub process { ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ && (defined($1) || defined($2)))) && !(($realfile ne '') && + defined($acpi_testexpected) && ($realfile eq $acpi_testexpected))) { $reported_maintainer_file = 1; WARN("added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr);
Signature · 1 line
Isaku Yamahata <[email protected]>
Quoted 12 lines · On Thu, 8 Apr 2021 10:49:13 -0700 Isaku Yamahata <[email protected]>…
How about initializing them explicitly as follows?
($realfile ne '') prevents the case realfile eq '' &&acpi_testexptedeq ''. Anyway your patch also should fix it. SoReviewed-by Isaku Yamahata <[email protected]>scripts/checkpatch.pl +0
-0
scripts/checkpatch.pl sub process { · line 1330
Quoted 8 lines
scripts/checkpatch.pl +2
-2@@ -1325,8 +1325,8 @@ sub process { my %suppress_whiletrailers; my %suppress_export; - my $acpi_testexpected; - my $acpi_nontestexpected; + my $acpi_testexpected = ''; + my $acpi_nontestexpected = '';
Hmm... I haven't tried but I believe this will break when these are passed to checkfilename() :
sub checkfilename {
my ($name, $acpi_testexpected, $acpi_nontestexpected) = @_;[...]
if (defined $$acpi_testexpected and defined $$acpi_nontestexpected) {
ERROR("Do not add expected files together with tests, " .
Quoted 35 lines
scripts/checkpatch.pl +0
-0# Pre-scan the patch sanitizing the lines.Quoted 28 lines · Greg Kurz
checkfilename()doesn't always set $acpi_testexpected. Fix the following warning:Use of uninitialized value $acpi_testexpected in string eq at
./scripts/checkpatch.plline 1529.Fixes d2f1af0e4120 ("checkpatch: don't emit warning on newly created acpi data files")Signed-off-by Greg Kurz <[email protected]>--- scripts/checkpatch.pl | 1 + 1 file changed, 1 insertion(+)scripts/checkpatch.pl +1
-0@@ -1532,6 +1532,7 @@ sub process { ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ && (defined($1) || defined($2)))) && !(($realfile ne '') && + defined($acpi_testexpected) && ($realfile eq $acpi_testexpected))) { $reported_maintainer_file = 1; WARN("added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr);
Quoted 27 lines · Greg Kurz
Quoted 12 lines · On Thu, 8 Apr 2021 10:49:13 -0700 Isaku Yamahata <[email protected]>…
How about initializing them explicitly as follows?
($realfile ne '') prevents the case realfile eq '' &&acpi_testexptedeq ''. Anyway your patch also should fix it. SoReviewed-by Isaku Yamahata <[email protected]>scripts/checkpatch.pl +0
-0scripts/checkpatch.pl sub process { · line 1330
Quoted 8 lines
scripts/checkpatch.pl +2
-2@@ -1325,8 +1325,8 @@ sub process { my %suppress_whiletrailers; my %suppress_export; - my $acpi_testexpected; - my $acpi_nontestexpected; + my $acpi_testexpected = ''; + my $acpi_nontestexpected = '';Hmm... I haven't tried but I believe this will break when these are passed to
checkfilename():
Quoted 8 lines
sub checkfilename { my ($name, $acpi_testexpected, $acpi_nontestexpected) = @_;[...]
if (defined $$acpi_testexpected and defined $$acpi_nontestexpected) {
ERROR("Do not add expected files together with tests, " .Quoted 1 line
scripts/checkpatch.pl +0
-0# Pre-scan the patch sanitizing the lines.
Oops. You're right. I scratch it.
Signature · 1 line
Isaku Yamahata <[email protected]>
Quoted 9 lines · Greg Kurz
checkfilename()doesn't always set $acpi_testexpected. Fix the following warning:Use of uninitialized value $acpi_testexpected in string eq at
./scripts/checkpatch.plline 1529.Fixes d2f1af0e4120 ("checkpatch: don't emit warning on newly created acpi data files")Signed-off-by Greg Kurz <[email protected]>
jinx ;-)
Subject: [RFC PATCH] scripts/checkpatch: fix uninitialised value check
Date: Thu, 8 Apr 2021 17:46:10 +0100
Message-Id: <[email protected]>
but as I failed to check the list first have a:
Quoted 16 lines
--- scripts/checkpatch.pl | 1 + 1 file changed, 1 insertion(+)scripts/checkpatch.pl +1
-0@@ -1532,6 +1532,7 @@ sub process { ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ && (defined($1) || defined($2)))) && !(($realfile ne '') && + defined($acpi_testexpected) && ($realfile eq $acpi_testexpected))) { $reported_maintainer_file = 1; WARN("added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr);
Signature · 1 line
Alex Bennée