]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Don't decrement an unsigned value past zero.
authorGuy Harris <[email protected]>
Thu, 1 Feb 2018 22:19:08 +0000 (14:19 -0800)
committerGuy Harris <[email protected]>
Thu, 1 Feb 2018 22:19:08 +0000 (14:19 -0800)
That also means we do one less decrement, so it's not as if testing
exp-- rather than testing exp and separately decrementing it is an
optimization.

print-olsr.c

index 7f446d6df302e46f4cd5df146309a82b109df989..cd96e95dfa1e4de0f1565f0ec7b2065b16922d59 100644 (file)
@@ -213,8 +213,9 @@ static uint32_t deserialize_gw_speed(uint8_t value) {
   speed = (value >> 3) + 1;
   exp = value & 7;
 
-  while (exp-- > 0) {
+  while (exp != 0) {
     speed *= 10;
+    exp--;
   }
   return speed;
 }