[Olsr-dev] [olsrd] [PATCH v2 1/2] gateway: fix serialize_gw_speed
Ferry Huberts
(spam-protected)
Wed Jul 18 18:30:37 CEST 2012
From: Ferry Huberts <(spam-protected)>
values over 32E7 would serialize to 0, which is not correct,
since they should be clipped to the maximum value of the
serialization range
Signed-off-by: Ferry Huberts <(spam-protected)>
---
src/gateway.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/gateway.c b/src/gateway.c
index 048a7cb..67b5779 100644
--- a/src/gateway.c
+++ b/src/gateway.c
@@ -62,10 +62,14 @@ static uint8_t
serialize_gw_speed(uint32_t speed) {
uint8_t exp = 0;
- if (speed == 0 || speed > 320000000) {
+ if (speed == 0) {
return 0;
}
+ if (speed > 320000000) {
+ return 0xff;
+ }
+
while (speed > 32 || (speed % 10) == 0) {
speed /= 10;
exp ++;
--
1.7.10.4
More information about the Olsr-dev
mailing list