Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
validation DataValidatorGroup::get_best() nullptr check
Browse files Browse the repository at this point in the history
 - fixes Coverity CID 139448
  • Loading branch information
dagar authored and bkueng committed Jun 14, 2018
1 parent c3e071e commit 4ae8242
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions validation/data_validator_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ DataValidatorGroup::get_best(uint64_t timestamp, int *index)
int max_index = -1;
DataValidator *best = nullptr;

unsigned i = 0;
int i = 0;

while (next != nullptr) {
float confidence = next->confidence(timestamp);

if (static_cast<int>(i) == pre_check_best) {
if (i == pre_check_best) {
pre_check_prio = next->priority();
pre_check_confidence = confidence;
}
Expand Down Expand Up @@ -186,10 +186,14 @@ DataValidatorGroup::get_best(uint64_t timestamp, int *index)
/* check whether the switch was a failsafe or preferring a higher priority sensor */
if (pre_check_prio != -1 && pre_check_prio < max_priority &&
fabsf(pre_check_confidence - max_confidence) < 0.1f) {

/* this is not a failover */
true_failsafe = false;

/* reset error flags, this is likely a hotplug sensor coming online late */
best->reset_state();
if (best != nullptr) {
best->reset_state();
}
}

/* if we're no initialized, initialize the bookkeeping but do not count a failsafe */
Expand Down

0 comments on commit 4ae8242

Please sign in to comment.