[PATCH] timer: Use the now parameter when it is not NULL

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Holger Hans Peter Freyther holger at freyther.de
Fri May 23 06:45:45 UTC 2014


From: Holger Hans Peter Freyther <holger at moiji-mobile.com>

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 5988aef..c8376c8 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(&current_time, NULL);
-		now = &current_time;
-	}
+	else
+		current_time = *now;
 
 	timersub(&timer->timeout, &current_time, remaining);
 
-- 
1.9.1





More information about the OpenBSC mailing list