Fix rxcost computation

This commit is contained in:
Matthias Schiffer 2012-10-07 18:19:41 +02:00
parent 650a9e8827
commit ec6a57a218

View file

@ -55,7 +55,11 @@ uint16_t ffd_neigh_get_rxcost(const ffd_neigh_t *neigh) {
int timediff = timespec_diff(&now, &neigh->last_hello); int timediff = timespec_diff(&now, &neigh->last_hello);
int shift = (timediff - neigh->hello_interval/2)/neigh->hello_interval; 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) if (received == 0)
return 0xffff; return 0xffff;