timer: Use the now parameter when it is not NULL

The code would have used an uninitialized current_time in case
"now" was not NULL. As now is const and timersub expects a non
const parameter I decided to copy now into current_time.

Fixes: CID #1040661
This commit is contained in:
Holger Hans Peter Freyther 2014-05-23 08:37:02 +02:00
parent 550b06c04c
commit 8e5435a864
1 changed files with 3 additions and 3 deletions

View File

@ -141,10 +141,10 @@ int osmo_timer_remaining(const struct osmo_timer_list *timer,
{
struct timeval current_time;
if (!now) {
if (!now)
gettimeofday(&current_time, NULL);
now = &current_time;
}
else
current_time = *now;
timersub(&timer->timeout, &current_time, remaining);