Make Coverity Scan happy (avoid division or modulo by zero)

This commit is contained in:
Carles Fernandez
2026-07-28 18:00:47 +02:00
parent 1c9fe3346f
commit 04997139c9
@@ -47,6 +47,11 @@ bool feed_alternating_bits(HistogramBitSynchronizer& synchronizer,
int detection_window_epochs = 3)
{
const int period = synchronizer.bins();
if (period <= 0)
{
ADD_FAILURE() << "The bit synchronizer must have a positive number of bins";
return false;
}
const int first_edge = (edge_phase == 0) ? period : edge_phase;
const int epochs = first_edge + (transition_count - 1) * period + detection_window_epochs;
float polarity = 1.0F;