Fix timeout calculation in sipe_buddy_subscribe_cb()
commit6995002614feec3404a91037a16d49fcc61e37e3
authorStefan Becker <stefan.becker@nokia.com>
Tue, 11 Aug 2009 18:41:46 +0000 (11 21:41 +0300)
committerStefan Becker <stefan.becker@nokia.com>
Tue, 11 Aug 2009 18:41:46 +0000 (11 21:41 +0300)
treea5240f5d528dc1d058defb8fb69d04d3d8cc3afd
parent6822c7ffb02c87c3ecc68d1fa6fc8bb5de74bab8
Fix timeout calculation in sipe_buddy_subscribe_cb()

If RAND_MAX == INT_MAX then the calculation for "timeout" always returns 0,
because the dividend can never be bigger than the divisor as it would then
need to exceed maximum integer range.

Convert the calculation to use unsigned integers. Multiply both terms of the
formula with 1 / time_range to scale the calculation to the limits of UINT_MAX.
It now should return a value in the right millisecond range.
src/sipe.c