From: Stephen L Johnson Date: Mon, 24 Jan 2000 03:36:21 +0000 (+0000) Subject: services() and service_objects where returning an undef instead of a null X-Git-Tag: spong-2_6b^0 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=37dbb7e2a14ac953b203415c63d6e5a990947a20;p=spong.git services() and service_objects where returning an undef instead of a null list if no ServiceList object was created. --- diff --git a/src/lib/Spong/Host.pm b/src/lib/Spong/Host.pm index dc3cb17..106a59a 100755 --- a/src/lib/Spong/Host.pm +++ b/src/lib/Spong/Host.pm @@ -37,6 +37,8 @@ use Spong::History; use Spong::Info; use POSIX; +use Data::Dumper; + package Spong::Host; # Constructor. This is a lazy constructor in that it doesn't get all it's @@ -128,13 +130,13 @@ sub service { sub service_objects { my( $self, $name ) = @_; my $servicelist = $self->services(); - return $servicelist->services() if $servicelist; + if ( $servicelist ) { return $servicelist->services(); } else { return (); } } sub service_names { my $self = shift; my $servicelist = $self->services(); - return $servicelist->names() if $servicelist; + if ( $servicelist ) { return $servicelist->names(); } else { return (); } } sub color { @@ -147,6 +149,7 @@ sub has_color { my( $self, $color ) = @_; foreach( $self->service_objects() ) { + if (! defined $_) { next; } if( $_->color() eq $color ) { return 1; } } return 0; @@ -351,6 +354,7 @@ sub _problem_service { my( $services, @problist, $probtime, $summary ); foreach $service ( $self->service_objects() ) { + if ( ! defined $service ) { next; } if( $service->has_problem() ) { push( @problist, $service->name() ); $summary = $service->summary(); @@ -377,6 +381,7 @@ sub _problem_message { my( $services, @problist, $probtime, $summary ); foreach $service ( $self->service_objects() ) { + if( ! defined $service ) { next; } if( $service->has_problem() ) { push( @problist, $service->name() ); $summary = $service->summary();