Commit 78b3098b authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Avoid overflow in neighbour_cost.

Thanks to Yoann Canal.
parent 449c8d59
...@@ -364,7 +364,7 @@ neighbour_cost(struct neighbour *neigh) ...@@ -364,7 +364,7 @@ neighbour_cost(struct neighbour *neigh)
directions. */ directions. */
a = MAX(a, 256); a = MAX(a, 256);
b = MAX(b, 256); b = MAX(b, 256);
/* 1/(alpha * beta), which is just plain ETX. */ /* 1/(alpha * beta), which is just plain ETX. Avoid overflow. */
return ((a * b + 128) >> 8); return ((a + 8) >> 4) * ((b + 8) >> 4);
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment