lkml.org 
[lkml]   [2021]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2] checkpatch: fix uninitialized return value in raw_line subroutine
Date
In case the second argument to raw_line subroutine is 0,
$line remains uninitialized and is returned back to the caller.
If the caller then tries to perform string concatenation with
that value, checkpatch throws an error:

Use of uninitialized value in concatenation (.) or string at
./scripts/checkpatch.pl line 1960.

Fix it by providing an empty string as the initial value
for $line.

Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
---

Changes in v2:
- Change commit message

scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 23697a6b1eaa..a98217360375 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1943,7 +1943,7 @@ sub raw_line {
my $offset = $linenr - 1;
$cnt++;

- my $line;
+ my $line = "";
while ($cnt) {
$line = $rawlines[$offset++];
next if (defined($line) && $line =~ /^-/);
--
2.30.0
\
 
 \ /
  Last update: 2021-04-25 09:45    [W:0.156 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site