diff --git a/clock.c b/clock.c index 7acb18e..89cdd78 100644 --- a/clock.c +++ b/clock.c @@ -578,7 +578,7 @@ static enum servo_state clock_no_adjust(struct clock *c, tmv_t ingress, if (f->count < f->max_count) { return state; } - if (tmv_eq(ingress, f->ingress1)) { + if (tmv_cmp(ingress, f->ingress1) == 0) { pr_warning("bad timestamps in rate ratio calculation"); return state; } diff --git a/mmedian.c b/mmedian.c index 1d15789..2383467 100644 --- a/mmedian.c +++ b/mmedian.c @@ -60,7 +60,8 @@ static tmv_t mmedian_sample(struct filter *filter, tmv_t sample) /* Insert index of the new value to order. */ for (i = m->cnt - 1; i > 0; i--) { - if (m->samples[m->order[i - 1]] <= m->samples[m->index]) + if (tmv_cmp(m->samples[m->order[i - 1]], + m->samples[m->index]) <= 0) break; m->order[i] = m->order[i - 1]; } diff --git a/port.c b/port.c index c3594d5..59e8b5e 100644 --- a/port.c +++ b/port.c @@ -933,7 +933,7 @@ static void port_nrate_calculate(struct port *p, tmv_t origin, tmv_t ingress) if (n->count < n->max_count) { return; } - if (tmv_eq(ingress, n->ingress1)) { + if (tmv_cmp(ingress, n->ingress1) == 0) { pr_warning("bad timestamps in nrate calculation"); return; } diff --git a/tmv.h b/tmv.h index 30b41ee..5717846 100644 --- a/tmv.h +++ b/tmv.h @@ -51,9 +51,9 @@ static inline tmv_t tmv_div(tmv_t a, int divisor) return a / divisor; } -static inline int tmv_eq(tmv_t a, tmv_t b) +static inline int tmv_cmp(tmv_t a, tmv_t b) { - return a == b ? 1 : 0; + return a == b ? 0 : a > b ? +1 : -1; } static inline int tmv_is_zero(tmv_t x)