aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Rutland <mark.rutland@arm.com>2017-01-09 17:19:24 +0000
committerMark Rutland <mark.rutland@arm.com>2017-01-09 17:37:41 +0000
commita184c6afdf8989b3baea864e65cf9260c24d1cfc (patch)
treed214dc68a1ac9084e24543d9fe61751f3bd72113
parentb2ff532cb2969cebef2a711c6d9cee80e0ccfa21 (diff)
downloadboot-wrapper-aarch64-a184c6afdf8989b3baea864e65cf9260c24d1cfc.tar.gz
FDT.pm: consistently check defined()
In a few cases, we check not $var to check if a var has a defined value. This also catches the case where $var has a defined value, but evaluates to false (e.g. if $var is zero). In FDT::Node::get_translated_reg(), this erroneous check means that reg entries with an address zero will not be translated, even where there is a valid set of ranges properties in parent nodes. Elsewhere, this is simply inconsistent, but not otherwise harmful. Fix the code to use defined($var) consistently. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Reported-by: Vladimir Murzin <vladimir.murzin@arm.com> Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
-rwxr-xr-xFDT.pm8
1 files changed, 4 insertions, 4 deletions
diff --git a/FDT.pm b/FDT.pm
index 2315e2d..b814ef8 100755
--- a/FDT.pm
+++ b/FDT.pm
@@ -211,7 +211,7 @@ sub parse
for (;;) {
$child = FDT::Node->parse($fh, $header, $self);
- last if (not $child);
+ last if (not defined($child));
push (@children, $child);
}
@@ -310,7 +310,7 @@ sub translate_address
my $parent = $self->{parent};
# root node require no translation
- return $addr if (not $parent);
+ return $addr if (not defined($parent));
my $ranges = $self->get_property("ranges");
if (not defined($ranges)) {
@@ -364,7 +364,7 @@ sub get_translated_reg
my ($addr, $size) = $reg->read_cell_list($off, [$ac, $sc]);
for (my $parent = $self->{parent}; $parent; $parent = $parent->{parent}) {
- last if (not $addr);
+ last if (not defined($addr));
$addr = $parent->translate_address($addr);
}
@@ -394,7 +394,7 @@ sub parse
if ($len != 0) {
$self->{data} = FDT::read_padded_data($fh, $len);
}
- goto failed if ($len and not $self->{data});
+ goto failed if ($len and not defined($self->{data}));
$self->{len} = $len;