From 55fc0e51ffc935f8cad6f1c8105b3884cf72d14c Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 20 May 2025 10:33:20 +0200 Subject: [PATCH 1/2] Checkable#process_check_result(): don't pass NULL CR to Checkable#ProcessCheckResult() It's ignored anyway. --- lib/icinga/checkable-script.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/icinga/checkable-script.cpp b/lib/icinga/checkable-script.cpp index fe08f32d3..764a9f851 100644 --- a/lib/icinga/checkable-script.cpp +++ b/lib/icinga/checkable-script.cpp @@ -14,7 +14,10 @@ static void CheckableProcessCheckResult(const CheckResult::Ptr& cr) ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); Checkable::Ptr self = vframe->Self; REQUIRE_NOT_NULL(self); - self->ProcessCheckResult(cr); + + if (cr) { + self->ProcessCheckResult(cr); + } } Object::Ptr Checkable::GetPrototype() From 69d2a0442a77e48442bd843e0fb9f82a9e9a88f3 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 20 May 2025 10:41:26 +0200 Subject: [PATCH 2/2] Remove unused ProcessingResult::NoCheckResult No one passes a NULL CR to Checkable#ProcessCheckResult() anymore. --- lib/icinga/apiactions.cpp | 2 -- lib/icinga/checkable-check.cpp | 5 ++--- lib/icinga/checkable.hpp | 1 - 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/icinga/apiactions.cpp b/lib/icinga/apiactions.cpp index 3892de776..0f7e5cff1 100644 --- a/lib/icinga/apiactions.cpp +++ b/lib/icinga/apiactions.cpp @@ -130,8 +130,6 @@ Dictionary::Ptr ApiActions::ProcessCheckResult(const ConfigObject::Ptr& object, switch (result) { case Result::Ok: return ApiActions::CreateResult(200, "Successfully processed check result for object '" + checkable->GetName() + "'."); - case Result::NoCheckResult: - return ApiActions::CreateResult(400, "Could not process check result for object '" + checkable->GetName() + "' because no check result was passed."); case Result::CheckableInactive: return ApiActions::CreateResult(503, "Could not process check result for object '" + checkable->GetName() + "' because the object is inactive."); case Result::NewerCheckResultPresent: diff --git a/lib/icinga/checkable-check.cpp b/lib/icinga/checkable-check.cpp index 2e96df5af..868921dc9 100644 --- a/lib/icinga/checkable-check.cpp +++ b/lib/icinga/checkable-check.cpp @@ -100,14 +100,13 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr { using Result = Checkable::ProcessingResult; + VERIFY(cr); + { ObjectLock olock(this); m_CheckRunning = false; } - if (!cr) - return Result::NoCheckResult; - double now = Utility::GetTime(); if (cr->GetScheduleStart() == 0) diff --git a/lib/icinga/checkable.hpp b/lib/icinga/checkable.hpp index 98c015ed6..da6be5630 100644 --- a/lib/icinga/checkable.hpp +++ b/lib/icinga/checkable.hpp @@ -119,7 +119,6 @@ public: enum class ProcessingResult { Ok, - NoCheckResult, CheckableInactive, NewerCheckResultPresent, };