From 2ebee010f03e7e27eb45add59e65b4c1ca64ff1c Mon Sep 17 00:00:00 2001 From: Julian Brost Date: Mon, 31 Mar 2025 13:21:02 +0200 Subject: [PATCH] Host::GetHost(): return early to remove a nesting level No change in functionality. The first two branches actually set the final return value for the method, so they can just return directly, removing the need to have the rest of the function inside an else block. --- lib/icinga/host.cpp | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/lib/icinga/host.cpp b/lib/icinga/host.cpp index 0fe7ec8eb..0dbe361a9 100644 --- a/lib/icinga/host.cpp +++ b/lib/icinga/host.cpp @@ -170,29 +170,30 @@ HostState Host::GetLastHardState() const * sort by severity. It is therefore easier to keep them seperated here. */ int Host::GetSeverity() const { - int severity = 0; - ObjectLock olock(this); HostState state = GetState(); if (!HasBeenChecked()) { - severity = 16; - } else if (state == HostUp) { - severity = 0; - } else { - if (IsReachable()) { - severity = 64; - } else { - severity = 32; - } + return 16; + } + if (state == HostUp) { + return 0; + } - if (IsAcknowledged()) { - severity += 512; - } else if (IsInDowntime()) { - severity += 256; - } else { - severity += 2048; - } + int severity = 0; + + if (IsReachable()) { + severity = 64; + } else { + severity = 32; + } + + if (IsAcknowledged()) { + severity += 512; + } else if (IsInDowntime()) { + severity += 256; + } else { + severity += 2048; } olock.Unlock();