From 8e5435a864da30ec0210f36fdff464a72cc5b31a Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 23 May 2014 08:37:02 +0200 Subject: [PATCH] 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 --- src/timer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/timer.c b/src/timer.c index 5988aef97..c8376c8ae 100644 --- a/src/timer.c +++ b/src/timer.c @@ -141,10 +141,10 @@ int osmo_timer_remaining(const struct osmo_timer_list *timer, { struct timeval current_time; - if (!now) { + if (!now) gettimeofday(¤t_time, NULL); - now = ¤t_time; - } + else + current_time = *now; timersub(&timer->timeout, ¤t_time, remaining);