Skip to content

Commit

Permalink
fix: increase index only when traffic buffer size doesn't decrease
Browse files Browse the repository at this point in the history
  • Loading branch information
asimopunov committed Apr 17, 2024
1 parent 03537e6 commit 4a3e920
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib/adsb/AdsbConflict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,15 @@ void AdsbConflict::get_traffic_state()

void AdsbConflict::remove_expired_conflicts()
{
for (uint8_t traffic_index = 0; traffic_index < _traffic_buffer.timestamp.size(); traffic_index++) {
for (uint8_t traffic_index = 0; traffic_index < _traffic_buffer.timestamp.size();) {
if (hrt_elapsed_time(&_traffic_buffer.timestamp[traffic_index]) > TRAFFIC_CONFLICT_LIFETIME) {
events::send<uint32_t>(events::ID("navigator_traffic_expired"), events::Log::Notice,
"Traffic Conflict {1} Expired and removed from buffer",
_traffic_buffer.icao_address[traffic_index]);
remove_icao_address_from_conflict_list(traffic_index);

} else {
traffic_index++;
}
}
}
Expand Down

0 comments on commit 4a3e920

Please sign in to comment.