summaryrefslogtreecommitdiffstats
path: root/perl
diff options
context:
space:
mode:
authorMatthew Booth <mbooth@redhat.com>2009-08-19 15:51:27 +0100
committerMatthew Booth <mbooth@redhat.com>2009-08-19 15:52:10 +0100
commit0a016df319420f9291c806bf8c8b528705b1bdc5 (patch)
tree4db562760efa9351acccf6be6646ecfc31dd2b1e /perl
parent2f3a0e3975ddecce2330324a152530c5b99f22f9 (diff)
downloadlibguestfs-0a016df319420f9291c806bf8c8b528705b1bdc5.tar.gz
libguestfs-0a016df319420f9291c806bf8c8b528705b1bdc5.tar.xz
libguestfs-0a016df319420f9291c806bf8c8b528705b1bdc5.zip
Cleanup initialisation of hash entries in Lib.pm
Diffstat (limited to 'perl')
-rw-r--r--perl/lib/Sys/Guestfs/Lib.pm17
1 files changed, 4 insertions, 13 deletions
diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm
index dfa79afc..96ada0d6 100644
--- a/perl/lib/Sys/Guestfs/Lib.pm
+++ b/perl/lib/Sys/Guestfs/Lib.pm
@@ -1558,12 +1558,8 @@ sub _check_for_kernels
# Check the kernel was recognised
if(defined($kernel)) {
# Put this kernel on the top level kernel list
- my $kernels = $os->{kernels};
- if(!defined($kernels)) {
- $kernels = [];
- $os->{kernels} = $kernels;
- }
- push(@$kernels, $kernel);
+ $os->{kernels} ||= [];
+ push(@{$os->{kernels}}, $kernel);
$config{kernel} = $kernel;
@@ -1766,13 +1762,8 @@ sub _inspect_initrd
}
# Add to the top level initrd_modules entry
- my $initrd_modules = $os->{initrd_modules};
- if(!defined($initrd_modules)) {
- $initrd_modules = {};
- $os->{initrd_modules} = $initrd_modules;
- }
-
- $initrd_modules->{$version} = \@modules;
+ $os->{initrd_modules} ||= {};
+ $os->{initrd_modules}->{$version} = \@modules;
return \@modules;
}