Subject: | [PATCH] Initialize $data{structures} to 0 when it's not found. |
Date: | Wed, 24 Feb 2010 17:16:17 -0500 |
To: | bug-parse-dmidecode [...] rt.cpan.org |
From: | "Dave O'Neill" <dmo [...] roaringpenguin.com> |
This prevents a "Use of uninitialized value" warning when parsing incomplete
dmidecode output
diff --git a/lib/Parse/DMIDecode.pm b/lib/Parse/DMIDecode.pm
index 441bff1..d5835c0 100644
--- a/lib/Parse/DMIDecode.pm
+++ b/lib/Parse/DMIDecode.pm
@@ -170,10 +170,13 @@ sub parse {
}
}
- for (qw(dmidecode structures bytes dmi smbios location)) {
+ for (qw(dmidecode bytes dmi smbios location)) {
$data{$_} = undef if !exists $data{$_};
}
+ # {structures} should be zero if missing, as we use it in comparisons below.
+ $data{structures} = 0 if !exists $data{structures};
+
my $raw_handle_data = '';
for (; $i < @lines; $i++) {
if ($lines[$i] =~ /^Handle [0-9A-Fx]+/) {
--
Dave O'Neill <dmo@roaringpenguin.com> Roaring Penguin Software Inc.
+1 (613) 231-6599 http://www.roaringpenguin.com/
For CanIt technical support, please mail: support@roaringpenguin.com