mirror of
https://github.com/Icinga/icinga2.git
synced 2025-04-08 17:05:25 +02:00
Service::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.
This commit is contained in:
parent
5ca6047b35
commit
01acfb47a9
@ -111,39 +111,40 @@ Host::Ptr Service::GetHost() const
|
||||
* sort by severity. It is therefore easier to keep them seperated here. */
|
||||
int Service::GetSeverity() const
|
||||
{
|
||||
int severity;
|
||||
|
||||
ObjectLock olock(this);
|
||||
ServiceState state = GetStateRaw();
|
||||
|
||||
if (!HasBeenChecked()) {
|
||||
severity = 16;
|
||||
} else if (state == ServiceOK) {
|
||||
severity = 0;
|
||||
} else {
|
||||
if (state == ServiceWarning) {
|
||||
severity = 32;
|
||||
} else if (state == ServiceUnknown) {
|
||||
severity = 64;
|
||||
} else if (state == ServiceCritical) {
|
||||
severity = 128;
|
||||
} else {
|
||||
severity = 256;
|
||||
}
|
||||
|
||||
Host::Ptr host = GetHost();
|
||||
ObjectLock hlock (host);
|
||||
if (host->GetState() != HostUp) {
|
||||
severity += 1024;
|
||||
} else if (IsAcknowledged()) {
|
||||
severity += 512;
|
||||
} else if (IsInDowntime()) {
|
||||
severity += 256;
|
||||
} else {
|
||||
severity += 2048;
|
||||
}
|
||||
hlock.Unlock();
|
||||
return 16;
|
||||
}
|
||||
if (state == ServiceOK) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int severity = 0;
|
||||
|
||||
if (state == ServiceWarning) {
|
||||
severity = 32;
|
||||
} else if (state == ServiceUnknown) {
|
||||
severity = 64;
|
||||
} else if (state == ServiceCritical) {
|
||||
severity = 128;
|
||||
} else {
|
||||
severity = 256;
|
||||
}
|
||||
|
||||
Host::Ptr host = GetHost();
|
||||
ObjectLock hlock (host);
|
||||
if (host->GetState() != HostUp) {
|
||||
severity += 1024;
|
||||
} else if (IsAcknowledged()) {
|
||||
severity += 512;
|
||||
} else if (IsInDowntime()) {
|
||||
severity += 256;
|
||||
} else {
|
||||
severity += 2048;
|
||||
}
|
||||
hlock.Unlock();
|
||||
|
||||
olock.Unlock();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user