avoid division by zero on certain platforms
authorSven-Ola Tuecke <sven-ola@gmx.de>
Thu, 12 Jun 2008 06:52:41 +0000 (08:52 +0200)
committerSven-Ola Tuecke <sven-ola@gmx.de>
Thu, 12 Jun 2008 06:52:41 +0000 (08:52 +0200)
src/scheduler.c

index 5d83bfd..7c0d724 100644 (file)
@@ -209,7 +209,7 @@ olsr_jitter(unsigned int rel_time, olsr_u8_t jitter_pct, unsigned int random)
    * Play some tricks to avoid overflows with integer arithmetic.
    */
   jitter_time = (jitter_pct * rel_time) / 100;
-  jitter_time = random / (RAND_MAX / jitter_time);
+  jitter_time = random / (1 + RAND_MAX / jitter_time);
 
 #if 0
   OLSR_PRINTF(3, "TIMER: jitter %u%% rel_time %ums to %ums\n",