From ec6a57a218b4bf4bf6d2e6ae1a6a4db59aa79f64 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 7 Oct 2012 18:19:41 +0200 Subject: Fix rxcost computation --- ffd/neigh.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ffd/neigh.c b/ffd/neigh.c index 74ff1b5..ca72ccc 100644 --- a/ffd/neigh.c +++ b/ffd/neigh.c @@ -55,7 +55,11 @@ uint16_t ffd_neigh_get_rxcost(const ffd_neigh_t *neigh) { int timediff = timespec_diff(&now, &neigh->last_hello); int shift = (timediff - neigh->hello_interval/2)/neigh->hello_interval; - int received = __builtin_popcount(neigh->hello_log << shift); + + if (shift >= 16) + return 0xffff; + + int received = __builtin_popcount((neigh->hello_log << shift) & 0xffff); if (received == 0) return 0xffff; -- cgit v1.2.3