mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 05:03:34 +08:00
validation DataValidatorGroup::get_best() nullptr check
- fixes Coverity CID 139448
This commit is contained in:
@@ -147,12 +147,12 @@ DataValidatorGroup::get_best(uint64_t timestamp, int *index)
|
|||||||
int max_index = -1;
|
int max_index = -1;
|
||||||
DataValidator *best = nullptr;
|
DataValidator *best = nullptr;
|
||||||
|
|
||||||
unsigned i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (next != nullptr) {
|
while (next != nullptr) {
|
||||||
float confidence = next->confidence(timestamp);
|
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_prio = next->priority();
|
||||||
pre_check_confidence = confidence;
|
pre_check_confidence = confidence;
|
||||||
}
|
}
|
||||||
@@ -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 */
|
/* check whether the switch was a failsafe or preferring a higher priority sensor */
|
||||||
if (pre_check_prio != -1 && pre_check_prio < max_priority &&
|
if (pre_check_prio != -1 && pre_check_prio < max_priority &&
|
||||||
fabsf(pre_check_confidence - max_confidence) < 0.1f) {
|
fabsf(pre_check_confidence - max_confidence) < 0.1f) {
|
||||||
|
|
||||||
/* this is not a failover */
|
/* this is not a failover */
|
||||||
true_failsafe = false;
|
true_failsafe = false;
|
||||||
|
|
||||||
/* reset error flags, this is likely a hotplug sensor coming online late */
|
/* 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 */
|
/* if we're no initialized, initialize the bookkeeping but do not count a failsafe */
|
||||||
|
|||||||
Reference in New Issue
Block a user