]> granicus.if.org Git - icinga2/commitdiff
Remove redundant checks.
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 15 Nov 2013 13:01:30 +0000 (14:01 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Thu, 21 Nov 2013 11:23:55 +0000 (12:23 +0100)
Fixes #5071

12 files changed:
components/compat/compatlogger.cpp
components/compat/statusdatawriter.cpp
components/livestatus/hoststable.cpp
components/perfdata/perfdatawriter.cpp
lib/db_ido/dbobject.cpp
lib/db_ido/servicedbobject.cpp
lib/icinga/compatutility.cpp
lib/icinga/externalcommandprocessor.cpp
lib/icinga/host.cpp
lib/icinga/notification.cpp
lib/icinga/service-check.cpp
lib/icinga/service.cpp

index 86236ddfbfecc1b0f1f78fac0b89951033dd1590..75fd435eac62a54f6af00845989a22ca78dff245 100644 (file)
@@ -76,9 +76,6 @@ void CompatLogger::CheckResultHandler(const Service::Ptr& service, const CheckRe
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        Dictionary::Ptr vars_after = cr->GetVarsAfter();
 
        long state_after = vars_after->Get("state");
@@ -151,9 +148,6 @@ void CompatLogger::TriggerDowntimeHandler(const Service::Ptr& service, const Dow
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        if (!downtime)
                return;
 
@@ -197,9 +191,6 @@ void CompatLogger::RemoveDowntimeHandler(const Service::Ptr& service, const Down
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        if (!downtime)
                return;
 
@@ -256,9 +247,6 @@ void CompatLogger::NotificationSentHandler(const Service::Ptr& service, const Us
 {
         Host::Ptr host = service->GetHost();
 
-        if (!host)
-                return;
-
        String notification_type_str = Notification::NotificationTypeToString(notification_type);
 
        String author_comment = "";
@@ -323,9 +311,6 @@ void CompatLogger::FlappingHandler(const Service::Ptr& service, FlappingState fl
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        String flapping_state_str;
        String flapping_output;
 
@@ -398,9 +383,6 @@ void CompatLogger::EventCommandHandler(const Service::Ptr& service)
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        EventCommand::Ptr event_command = service->GetEventCommand();
        String event_command_name = event_command->GetName();
        String state = Service::StateToString(service->GetState());
@@ -526,9 +508,6 @@ void CompatLogger::ReopenFile(bool rotate)
        BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjects<Service>()) {
                Host::Ptr host = service->GetHost();
 
-               if (!host)
-                       continue;
-
                String output;
                CheckResult::Ptr cr = service->GetLastCheckResult();
 
index 4601e59d39fc4c276e56107ec7339f066cdc2be8..b024b21276a3b2771c3bea440b440c2c2512fbff 100644 (file)
@@ -69,9 +69,6 @@ void StatusDataWriter::DumpComments(std::ostream& fp, const Service::Ptr& owner,
 
        Host::Ptr host = owner->GetHost();
 
-       if (!host)
-               return;
-
        ObjectLock olock(comments);
 
        String id;
@@ -166,9 +163,6 @@ void StatusDataWriter::DumpDowntimes(std::ostream& fp, const Service::Ptr& owner
 {
        Host::Ptr host = owner->GetHost();
 
-       if (!host)
-               return;
-
        Dictionary::Ptr downtimes = owner->GetDowntimes();
 
        ObjectLock olock(downtimes);
@@ -384,9 +378,6 @@ void StatusDataWriter::DumpServiceStatus(std::ostream& fp, const Service::Ptr& s
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        fp << "servicestatus {" << "\n"
           << "\t" << "host_name=" << host->GetName() << "\n"
           << "\t" << "service_description=" << service->GetShortName() << "\n";
@@ -407,9 +398,6 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
         String check_period_str;
         TimePeriod::Ptr check_period = service->GetCheckPeriod();
         if (check_period)
@@ -505,9 +493,6 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s
        BOOST_FOREACH(const Service::Ptr& parent, service->GetParentServices()) {
                Host::Ptr host = service->GetHost();
 
-               if (!host)
-                       continue;
-
                Host::Ptr parent_host = parent->GetHost();
 
                if (!parent_host)
@@ -659,9 +644,6 @@ void StatusDataWriter::StatusTimerHandler(void)
                BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
                        Host::Ptr host = service->GetHost();
 
-                       if (!host)
-                               continue;
-
                        sglist.push_back(host->GetName());
                        sglist.push_back(service->GetShortName());
                }
index 9abae23c0a70fde600aa488876acb667d749ec82..ee9c401eff57d73f5882b3e6d04e808a04a257bd 100644 (file)
@@ -175,9 +175,6 @@ Value HostsTable::NameAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        return host->GetName();
 }
 
@@ -185,9 +182,6 @@ Value HostsTable::DisplayNameAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        return host->GetDisplayName();
 }
 
@@ -195,9 +189,6 @@ Value HostsTable::AddressAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Dictionary::Ptr macros = host->GetMacros();
 
        if (!macros)
@@ -210,9 +201,6 @@ Value HostsTable::Address6Accessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Dictionary::Ptr macros = host->GetMacros();
 
        if (!macros)
@@ -223,12 +211,8 @@ Value HostsTable::Address6Accessor(const Value& row)
 
 Value HostsTable::CheckCommandAccessor(const Value& row)
 {
-
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        /* use hostcheck service */
        Service::Ptr hc = host->GetCheckService();
 
@@ -247,9 +231,6 @@ Value HostsTable::CheckCommandExpandedAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -298,9 +279,6 @@ Value HostsTable::EventHandlerAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -318,9 +296,6 @@ Value HostsTable::NotificationPeriodAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -344,9 +319,6 @@ Value HostsTable::CheckPeriodAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -364,9 +336,6 @@ Value HostsTable::NotesAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Dictionary::Ptr custom = host->GetCustom();
 
        if (!custom)
@@ -379,9 +348,6 @@ Value HostsTable::NotesExpandedAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr service = host->GetCheckService();
 
        if (!service)
@@ -409,9 +375,6 @@ Value HostsTable::NotesUrlAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Dictionary::Ptr custom = host->GetCustom();
 
        if (!custom)
@@ -424,9 +387,6 @@ Value HostsTable::NotesUrlExpandedAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr service = host->GetCheckService();
 
        if (!service)
@@ -454,9 +414,6 @@ Value HostsTable::ActionUrlAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Dictionary::Ptr custom = host->GetCustom();
 
        if (!custom)
@@ -469,9 +426,6 @@ Value HostsTable::ActionUrlExpandedAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr service = host->GetCheckService();
 
        if (!service)
@@ -500,9 +454,6 @@ Value HostsTable::PluginOutputAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
        String output;
 
@@ -524,9 +475,6 @@ Value HostsTable::PerfDataAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
        String perfdata;
 
@@ -545,9 +493,6 @@ Value HostsTable::IconImageAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Dictionary::Ptr custom = host->GetCustom();
 
        if (!custom)
@@ -560,9 +505,6 @@ Value HostsTable::IconImageExpandedAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr service = host->GetCheckService();
 
        if (!service)
@@ -590,9 +532,6 @@ Value HostsTable::IconImageAltAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Dictionary::Ptr custom = host->GetCustom();
 
        if (!custom)
@@ -605,9 +544,6 @@ Value HostsTable::StatusmapImageAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Dictionary::Ptr custom = host->GetCustom();
 
        if (!custom)
@@ -621,9 +557,6 @@ Value HostsTable::LongPluginOutputAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
        String long_output;
 
@@ -645,9 +578,6 @@ Value HostsTable::MaxCheckAttemptsAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -661,9 +591,6 @@ Value HostsTable::FlapDetectionEnabledAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -677,9 +604,6 @@ Value HostsTable::AcceptPassiveChecksAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -693,9 +617,6 @@ Value HostsTable::EventHandlerEnabledAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -713,9 +634,6 @@ Value HostsTable::AcknowledgementTypeAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -732,9 +650,6 @@ Value HostsTable::CheckTypeAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -747,9 +662,6 @@ Value HostsTable::LastStateAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        return host->GetLastState();
 }
 
@@ -757,9 +669,6 @@ Value HostsTable::LastHardStateAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        return host->GetLastHardState();
 }
 
@@ -768,9 +677,6 @@ Value HostsTable::CurrentAttemptAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -784,9 +690,6 @@ Value HostsTable::LastNotificationAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -807,9 +710,6 @@ Value HostsTable::NextNotificationAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -830,9 +730,6 @@ Value HostsTable::NextCheckAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -846,9 +743,6 @@ Value HostsTable::LastHardStateChangeAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -862,9 +756,6 @@ Value HostsTable::HasBeenCheckedAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -878,9 +769,6 @@ Value HostsTable::CurrentNotificationNumberAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -901,9 +789,6 @@ Value HostsTable::TotalServicesAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        return host->GetTotalServices();
 }
 
@@ -912,9 +797,6 @@ Value HostsTable::ChecksEnabledAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -928,9 +810,6 @@ Value HostsTable::NotificationsEnabledAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -944,9 +823,6 @@ Value HostsTable::AcknowledgedAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -963,9 +839,6 @@ Value HostsTable::StateAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        return host->GetState();
 }
 
@@ -974,9 +847,6 @@ Value HostsTable::StateTypeAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        return host->GetStateType();
 }
 
@@ -985,9 +855,6 @@ Value HostsTable::NoMoreNotificationsAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1011,9 +878,6 @@ Value HostsTable::LastCheckAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1027,9 +891,6 @@ Value HostsTable::LastStateChangeAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        return static_cast<int>(host->GetLastStateChange());
 }
 
@@ -1038,9 +899,6 @@ Value HostsTable::LastTimeUpAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        return static_cast<int>(host->GetLastStateUp());
 }
 
@@ -1049,9 +907,6 @@ Value HostsTable::LastTimeDownAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        return static_cast<int>(host->GetLastStateDown());
 }
 
@@ -1060,9 +915,6 @@ Value HostsTable::LastTimeUnreachableAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        return static_cast<int>(host->GetLastStateUnreachable());
 }
 
@@ -1071,9 +923,6 @@ Value HostsTable::IsFlappingAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1087,9 +936,6 @@ Value HostsTable::ScheduledDowntimeDepthAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1104,9 +950,6 @@ Value HostsTable::ActiveChecksEnabledAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1126,9 +969,6 @@ Value HostsTable::ModifiedAttributesAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1148,9 +988,6 @@ Value HostsTable::CheckIntervalAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1164,9 +1001,6 @@ Value HostsTable::RetryIntervalAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1180,9 +1014,6 @@ Value HostsTable::NotificationIntervalAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1206,9 +1037,6 @@ Value HostsTable::LowFlapThresholdAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1222,9 +1050,6 @@ Value HostsTable::HighFlapThresholdAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1237,9 +1062,6 @@ Value HostsTable::X2dAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Dictionary::Ptr custom = host->GetCustom();
 
        if (!custom)
@@ -1260,9 +1082,6 @@ Value HostsTable::Y2dAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Dictionary::Ptr custom = host->GetCustom();
 
        if (!custom)
@@ -1284,9 +1103,6 @@ Value HostsTable::LatencyAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1300,9 +1116,6 @@ Value HostsTable::ExecutionTimeAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1316,9 +1129,6 @@ Value HostsTable::PercentStateChangeAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1332,9 +1142,6 @@ Value HostsTable::InNotificationPeriodAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1359,9 +1166,6 @@ Value HostsTable::InCheckPeriodAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1381,9 +1185,6 @@ Value HostsTable::ContactsAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1403,9 +1204,6 @@ Value HostsTable::DowntimesAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1438,9 +1236,6 @@ Value HostsTable::DowntimesWithInfoAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1477,9 +1272,6 @@ Value HostsTable::CommentsAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1512,9 +1304,6 @@ Value HostsTable::CommentsWithInfoAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1551,9 +1340,6 @@ Value HostsTable::CommentsWithExtraInfoAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1591,9 +1377,6 @@ Value HostsTable::CustomVariableNamesAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Dictionary::Ptr customvars;
 
        {
@@ -1619,9 +1402,6 @@ Value HostsTable::CustomVariableValuesAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Dictionary::Ptr customvars;
 
        {
@@ -1647,9 +1427,6 @@ Value HostsTable::CustomVariablesAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Dictionary::Ptr customvars;
 
        {
@@ -1678,9 +1455,6 @@ Value HostsTable::ParentsAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Array::Ptr parents = make_shared<Array>();
 
        BOOST_FOREACH(const Host::Ptr& parent, host->GetParentHosts()) {
@@ -1694,9 +1468,6 @@ Value HostsTable::ChildsAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Array::Ptr childs = make_shared<Array>();
 
        BOOST_FOREACH(const Host::Ptr& child, host->GetChildHosts()) {
@@ -1711,9 +1482,6 @@ Value HostsTable::NumServicesAccessor(const Value& row)
        /* duplicate of TotalServices */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        return host->GetTotalServices();
 }
 
@@ -1721,9 +1489,6 @@ Value HostsTable::WorstServiceStateAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Value worst_service = StateOK;
 
        BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
@@ -1738,9 +1503,6 @@ Value HostsTable::NumServicesOkAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        int num_services = 0;
 
        BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
@@ -1755,9 +1517,6 @@ Value HostsTable::NumServicesWarnAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        int num_services = 0;
 
        BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
@@ -1772,9 +1531,6 @@ Value HostsTable::NumServicesCritAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        int num_services = 0;
 
        BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
@@ -1789,9 +1545,6 @@ Value HostsTable::NumServicesUnknownAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        int num_services = 0;
 
        BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
@@ -1806,9 +1559,6 @@ Value HostsTable::NumServicesPendingAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        int num_services = 0;
 
        BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
@@ -1823,9 +1573,6 @@ Value HostsTable::WorstServiceHardStateAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Value worst_service = StateOK;
 
        BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
@@ -1842,9 +1589,6 @@ Value HostsTable::NumServicesHardOkAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        int num_services = 0;
 
        BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
@@ -1859,9 +1603,6 @@ Value HostsTable::NumServicesHardWarnAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        int num_services = 0;
 
        BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
@@ -1876,9 +1617,6 @@ Value HostsTable::NumServicesHardCritAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        int num_services = 0;
 
        BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
@@ -1893,9 +1631,6 @@ Value HostsTable::NumServicesHardUnknownAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        int num_services = 0;
 
        BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
@@ -1911,9 +1646,6 @@ Value HostsTable::HardStateAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1932,9 +1664,6 @@ Value HostsTable::StalenessAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1950,9 +1679,6 @@ Value HostsTable::GroupsAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Array::Ptr groups = host->GetGroups();
 
        if (!groups)
@@ -1966,9 +1692,6 @@ Value HostsTable::ContactGroupsAccessor(const Value& row)
        /* use hostcheck service */
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Service::Ptr hc = host->GetCheckService();
 
        if (!hc)
@@ -1987,9 +1710,6 @@ Value HostsTable::ServicesAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Array::Ptr services = make_shared<Array>();
 
        BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
@@ -2003,9 +1723,6 @@ Value HostsTable::ServicesWithStateAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Array::Ptr services = make_shared<Array>();
 
        BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
@@ -2024,9 +1741,6 @@ Value HostsTable::ServicesWithInfoAccessor(const Value& row)
 {
        Host::Ptr host = static_cast<Host::Ptr>(row);
 
-       if (!host)
-               return Empty;
-
        Array::Ptr services = make_shared<Array>();
 
        BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
index b2cf76a70f435d2cf60eb4b2159fc6876a4e59e9..e402730809e2f5f2400317890f343482ba7a7a30 100644 (file)
@@ -53,9 +53,6 @@ void PerfdataWriter::CheckResultHandler(const Service::Ptr& service, const Check
 
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        std::vector<MacroResolver::Ptr> resolvers;
        resolvers.push_back(service);
        resolvers.push_back(host);
index e85856c8a9496c5f97486f2d330e7a55d900bfe5..dd12c7ad93aa3dfee829a9ee8a3073fb8a712a13 100644 (file)
@@ -165,9 +165,6 @@ DbObject::Ptr DbObject::GetOrCreateByObject(const DynamicObject::Ptr& object)
        if (service) {
                Host::Ptr host = service->GetHost();
 
-               if (!host)
-                       return DbObject::Ptr();
-
                name1 = service->GetHost()->GetName();
                name2 = service->GetShortName();
        } else {
index dbe1fc9d898bd4e6fec0cbc5068a41854da0931a..1f84cd7bedddadd7598248f5b0427237a24d0d9e 100644 (file)
@@ -83,9 +83,6 @@ Dictionary::Ptr ServiceDbObject::GetConfigFields(void) const
 
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return Dictionary::Ptr();
-
        Dictionary::Ptr attrs;
 
        {
@@ -328,9 +325,6 @@ void ServiceDbObject::OnConfigUpdate(void)
        /* service host config update */
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        if (host->GetCheckService() != service)
                return;
 
@@ -348,9 +342,6 @@ void ServiceDbObject::OnStatusUpdate(void)
        Host::Ptr host = service->GetHost();
 
        /* update the host if hostcheck service */
-       if (!host)
-               return;
-
        if (host->GetCheckService() != service)
                return;
 
@@ -391,9 +382,6 @@ void ServiceDbObject::AddCommentInternal(const Service::Ptr& service, const Comm
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        if (!comment) {
                Log(LogWarning, "db_ido", "comment does not exist. not adding it.");
                return;
@@ -459,9 +447,6 @@ void ServiceDbObject::RemoveComments(const Service::Ptr& service)
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        Log(LogDebug, "db_ido", "removing service comments for '" + service->GetName() + "'");
 
        DbQuery query1;
@@ -484,9 +469,6 @@ void ServiceDbObject::RemoveComment(const Service::Ptr& service, const Comment::
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        if (!comment) {
                Log(LogWarning, "db_ido", "comment does not exist. not deleting it.");
                return;
@@ -564,9 +546,6 @@ void ServiceDbObject::AddDowntimeInternal(const Service::Ptr& service, const Dow
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        if (!downtime) {
                Log(LogWarning, "db_ido", "downtime does not exist. not adding it.");
                return;
@@ -631,9 +610,6 @@ void ServiceDbObject::RemoveDowntimes(const Service::Ptr& service)
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        Log(LogDebug, "db_ido", "removing service downtimes for '" + service->GetName() + "'");
 
        DbQuery query1;
@@ -656,9 +632,6 @@ void ServiceDbObject::RemoveDowntime(const Service::Ptr& service, const Downtime
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        if (!downtime) {
                Log(LogWarning, "db_ido", "downtime does not exist. not adding it.");
                return;
@@ -712,9 +685,6 @@ void ServiceDbObject::TriggerDowntime(const Service::Ptr& service, const Downtim
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        if (!downtime) {
                Log(LogWarning, "db_ido", "downtime does not exist. not updating it.");
                return;
@@ -783,9 +753,6 @@ void ServiceDbObject::AddAcknowledgementHistory(const Service::Ptr& service, con
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        Log(LogDebug, "db_ido", "add acknowledgement history for '" + service->GetName() + "'");
 
        double now = Utility::GetTime();
@@ -828,9 +795,6 @@ void ServiceDbObject::AddContactNotificationHistory(const Service::Ptr& service,
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        Log(LogDebug, "db_ido", "add contact notification history for '" + service->GetName() + "'");
 
        /* start and end happen at the same time */
@@ -861,9 +825,6 @@ void ServiceDbObject::AddNotificationHistory(const Service::Ptr& service, const
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        Log(LogDebug, "db_ido", "add notification history for '" + service->GetName() + "'");
 
        /* start and end happen at the same time */
@@ -913,9 +874,6 @@ void ServiceDbObject::AddStateChangeHistory(const Service::Ptr& service, const C
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        Log(LogDebug, "db_ido", "add state change history for '" + service->GetName() + "'");
 
        double now = Utility::GetTime();
@@ -968,9 +926,6 @@ void ServiceDbObject::AddCheckResultLogHistory(const Service::Ptr& service, cons
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        Dictionary::Ptr vars_after = cr->GetVarsAfter();
 
        long state_after = vars_after->Get("state");
@@ -1063,9 +1018,6 @@ void ServiceDbObject::AddTriggerDowntimeLogHistory(const Service::Ptr& service,
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        if (!downtime)
                return;
 
@@ -1095,9 +1047,6 @@ void ServiceDbObject::AddRemoveDowntimeLogHistory(const Service::Ptr& service, c
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        if (!downtime)
                return;
 
@@ -1140,9 +1089,6 @@ void ServiceDbObject::AddNotificationSentLogHistory(const Service::Ptr& service,
 {
         Host::Ptr host = service->GetHost();
 
-        if (!host)
-                return;
-
        CheckCommand::Ptr commandObj = service->GetCheckCommand();
 
        String check_command = "";
@@ -1198,9 +1144,6 @@ void ServiceDbObject::AddFlappingLogHistory(const Service::Ptr& service, Flappin
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        String flapping_state_str;
        String flapping_output;
 
@@ -1248,9 +1191,6 @@ void ServiceDbObject::AddLogHistory(const Service::Ptr& service, String buffer,
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        Log(LogDebug, "db_ido", "add log entry history for '" + service->GetName() + "'");
 
        double now = Utility::GetTime();
@@ -1287,9 +1227,6 @@ void ServiceDbObject::AddFlappingHistory(const Service::Ptr& service, FlappingSt
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        Log(LogDebug, "db_ido", "add flapping history for '" + service->GetName() + "'");
 
        double now = Utility::GetTime();
@@ -1347,9 +1284,6 @@ void ServiceDbObject::AddServiceCheckHistory(const Service::Ptr& service, const
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        Log(LogDebug, "db_ido", "add service check history for '" + service->GetName() + "'");
 
        DbQuery query1;
@@ -1414,9 +1348,6 @@ void ServiceDbObject::AddEventHandlerHistory(const Service::Ptr& service)
 {
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return;
-
        Log(LogDebug, "db_ido", "add eventhandler history for '" + service->GetName() + "'");
 
        double now = Utility::GetTime();
index bc39bb8745fa1f62967234ec1d7fcfeb422059a8..431183dd699f384248e9f54bd471b8a73b9fe79c 100644 (file)
@@ -297,9 +297,6 @@ Dictionary::Ptr CompatUtility::GetServiceConfigAttributes(const Service::Ptr& se
 
        Host::Ptr host = service->GetHost();
 
-       if (!host)
-               return Dictionary::Ptr();
-
        String check_period_str;
        TimePeriod::Ptr check_period = service->GetCheckPeriod();
        if (check_period)
index 32efedd7a32d4d811d6e97b6f72af6ad0f87cdfc..f0e9d1f6cffa7f8a161ac5fca3737a60741371d8 100644 (file)
@@ -1522,9 +1522,6 @@ void ExternalCommandProcessor::DisableServicegroupHostChecks(double, const std::
        BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
                Host::Ptr host = service->GetHost();
 
-               if (!host)
-                       continue;
-
                Service::Ptr hc = host->GetCheckService();
 
                if (!hc)
@@ -1553,9 +1550,6 @@ void ExternalCommandProcessor::DisableServicegroupPassiveHostChecks(double, cons
        BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
                Host::Ptr host = service->GetHost();
 
-               if (!host)
-                       continue;
-
                Service::Ptr hc = host->GetCheckService();
 
                if (!hc)
@@ -1617,9 +1611,6 @@ void ExternalCommandProcessor::EnableServicegroupHostChecks(double, const std::v
        BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
                Host::Ptr host = service->GetHost();
 
-               if (!host)
-                       continue;
-
                Service::Ptr hc = host->GetCheckService();
 
                if (!hc)
@@ -1648,9 +1639,6 @@ void ExternalCommandProcessor::EnableServicegroupPassiveHostChecks(double, const
        BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
                Host::Ptr host = service->GetHost();
 
-               if (!host)
-                       continue;
-
                Service::Ptr hc = host->GetCheckService();
 
                if (!hc)
index 6291eba6d342314f785c57a3544b892fbc41539d..cac47e1b76fc642421c13188f8ae2b7f18bcca5a 100644 (file)
@@ -281,9 +281,6 @@ std::set<Host::Ptr> Host::GetParentHosts(void) const
 
                        Host::Ptr host = GetByName(value);
 
-                       if (!host)
-                               continue;
-
                        parents.insert(host);
                }
        }
index 3705ffd063871f15713c7621135113741d26493b..57ca6dbaa149110f4b7eeb16473483c824cdee04 100644 (file)
@@ -54,9 +54,6 @@ Service::Ptr Notification::GetService(void) const
 {
        Host::Ptr host = Host::GetByName(GetHostRaw());
 
-       if (!host)
-               return Service::Ptr();
-
        if (GetServiceRaw().IsEmpty())
                return host->GetCheckService();
        else
index 89a37b30fce6b95402089e71f8002a7270fd7f5e..21908610908495ba0e20d49708c49c83e1bc5076 100644 (file)
@@ -204,11 +204,7 @@ void Service::ProcessCheckResult(const CheckResult::Ptr& cr, const String& autho
 
        bool reachable = IsReachable();
 
-       Host::Ptr host = GetHost();
-       bool host_reachable = true;
-
-       if (host)
-               host_reachable = host->IsReachable();
+       bool host_reachable = GetHost()->IsReachable();
 
        ASSERT(!OwnsLock());
        ObjectLock olock(this);
@@ -470,14 +466,7 @@ void Service::ExecuteCheck(void)
        CheckResult::Ptr result;
 
        try {
-               CheckCommand::Ptr command = GetCheckCommand();
-
-               if (!command) {
-                       Log(LogDebug, "icinga", "No check_command found for service '" + GetName() + "'. Skipping execution.");
-                       return;
-               }
-
-               result = command->Execute(GetSelf());
+               result = GetCheckCommand()->Execute(GetSelf());
        } catch (const std::exception& ex) {
                std::ostringstream msgbuf;
                msgbuf << "Exception occured during check for service '"
@@ -510,9 +499,6 @@ void Service::ExecuteCheck(void)
        if (result)
                ProcessCheckResult(result);
 
-       /* figure out when the next check is for this service; the call to
-        * ProcessCheckResult() should've already done this but lets do it again
-        * just in case there was no check result. */
        UpdateNextCheck();
 
        {
@@ -525,9 +511,6 @@ void Service::UpdateStatistics(const CheckResult::Ptr& cr)
 {
        time_t ts = cr->GetScheduleEnd();
 
-       if (ts == 0)
-               ts = static_cast<time_t>(Utility::GetTime());
-
        if (cr->GetActive())
                CIB::UpdateActiveChecksStatistics(ts, 1);
        else
index 1eb4d84c1f173b1808f6102ee97a3276d2903607..532aa1dc074c6e2e33df39f437db05e020505d21 100644 (file)
@@ -220,8 +220,7 @@ std::set<Host::Ptr> Service::GetParentHosts(void) const
        Host::Ptr host = GetHost();
 
        /* The service's host is implicitly a parent. */
-       if (host)
-               parents.insert(host);
+       parents.insert(host);
 
        Array::Ptr dependencies = GetHostDependencies();
 
@@ -229,12 +228,7 @@ std::set<Host::Ptr> Service::GetParentHosts(void) const
                ObjectLock olock(dependencies);
 
                BOOST_FOREACH(const String& dependency, dependencies) {
-                       Host::Ptr host = Host::GetByName(dependency);
-
-                       if (!host)
-                               continue;
-
-                       parents.insert(host);
+                       parents.insert(Host::GetByName(dependency));
                }
        }
 
@@ -254,10 +248,7 @@ std::set<Service::Ptr> Service::GetParentServices(void) const
                BOOST_FOREACH(const Value& dependency, dependencies) {
                        Service::Ptr service = host->GetServiceByShortName(dependency);
 
-                       if (!service)
-                               continue;
-
-                       if (service->GetName() == GetName())
+                       if (!service || service->GetName() == GetName())
                                continue;
 
                        parents.insert(service);