Fix compiler warnings and style

This commit is contained in:
Michael Friedrich 2019-07-10 11:51:58 +02:00
parent ffa7b749cb
commit a3c6797310
2 changed files with 28 additions and 19 deletions

View File

@ -461,7 +461,7 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
for (int conflict : {NotificationProblem | NotificationRecovery, NotificationFlappingStart | NotificationFlappingEnd}) { for (int conflict : {NotificationProblem | NotificationRecovery, NotificationFlappingStart | NotificationFlappingEnd}) {
/* E.g. problem and recovery notifications neutralize each other. */ /* E.g. problem and recovery notifications neutralize each other. */
if (suppressed_types_after & conflict == conflict) { if ((suppressed_types_after & conflict) == conflict) {
suppressed_types_after &= ~conflict; suppressed_types_after &= ~conflict;
} }
} }

View File

@ -110,30 +110,38 @@ static void FireSuppressedNotifications(Checkable* checkable)
auto cr (checkable->GetLastCheckResult()); auto cr (checkable->GetLastCheckResult());
switch (type) { switch (type) {
case NotificationProblem: case NotificationProblem:
still_applies = cr && !checkable->IsStateOK(cr->GetState()) && checkable->GetStateType() == StateTypeHard; still_applies = cr && !checkable->IsStateOK(cr->GetState()) && checkable->GetStateType() == StateTypeHard;
break; break;
case NotificationRecovery: case NotificationRecovery:
still_applies = cr && checkable->IsStateOK(cr->GetState()); still_applies = cr && checkable->IsStateOK(cr->GetState());
break; break;
case NotificationFlappingStart: case NotificationFlappingStart:
still_applies = checkable->IsFlapping(); still_applies = checkable->IsFlapping();
break; break;
case NotificationFlappingEnd: case NotificationFlappingEnd:
still_applies = !checkable->IsFlapping(); still_applies = !checkable->IsFlapping();
break;
default:
break;
} }
if (still_applies) { if (still_applies) {
bool still_suppressed; bool still_suppressed;
switch (type) { switch (type) {
case NotificationProblem: case NotificationProblem:
case NotificationRecovery: /* Fall through. */
still_suppressed = !checkable->IsReachable(DependencyNotification) || checkable->IsInDowntime() || checkable->IsAcknowledged(); case NotificationRecovery:
break; still_suppressed = !checkable->IsReachable(DependencyNotification) || checkable->IsInDowntime() || checkable->IsAcknowledged();
case NotificationFlappingStart: break;
case NotificationFlappingEnd: case NotificationFlappingStart:
still_suppressed = checkable->IsInDowntime(); /* Fall through. */
case NotificationFlappingEnd:
still_suppressed = checkable->IsInDowntime();
break;
default:
break;
} }
if (!still_suppressed && checkable->GetEnableActiveChecks()) { if (!still_suppressed && checkable->GetEnableActiveChecks()) {
@ -169,6 +177,7 @@ static void FireSuppressedNotifications(Checkable* checkable)
if (subtract) { if (subtract) {
ObjectLock olock (checkable); ObjectLock olock (checkable);
int suppressed_types_before (checkable->GetSuppressedNotifications()); int suppressed_types_before (checkable->GetSuppressedNotifications());
int suppressed_types_after (suppressed_types_before & ~subtract); int suppressed_types_after (suppressed_types_before & ~subtract);