From 96f73a9b71de2c4a5600115f4bcee525955b966c Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 10 Jan 2016 14:02:03 +0100 Subject: [PATCH] sectionsd: fix possibly fishy localtime_r usage Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/4b6673dd91472088765905442face65d13656cd8 Author: Stefan Seyfried Date: 2016-01-10 (Sun, 10 Jan 2016) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/eitd/sectionsd.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/eitd/sectionsd.cpp b/src/eitd/sectionsd.cpp index 09362c0d9..66371d789 100644 --- a/src/eitd/sectionsd.cpp +++ b/src/eitd/sectionsd.cpp @@ -1384,15 +1384,14 @@ void CTimeThread::setSystemTime(time_t tim) { struct timeval tv; struct tm t; - time_t now = time(NULL); - struct tm *tmTime = localtime_r(&now, &t); gettimeofday(&tv, NULL); timediff = int64_t(tim * 1000000 - (tv.tv_usec + tv.tv_sec * 1000000)); + localtime_r(&tv.tv_sec, &t); - xprintf("%s: timediff %" PRId64 ", current: %02d.%02d.%04d %02d:%02d:%02d, dvb: %s", name.c_str(), timediff, - tmTime->tm_mday, tmTime->tm_mon+1, tmTime->tm_year+1900, - tmTime->tm_hour, tmTime->tm_min, tmTime->tm_sec, ctime(&tim)); + xprintf("%s: timediff %" PRId64 ", current: %02d.%02d.%04d %02d:%02d:%02d, dvb: %s", + name.c_str(), timediff, + t.tm_mday, t.tm_mon+1, t.tm_year+1900, t.tm_hour, t.tm_min, t.tm_sec, ctime(&tim)); #if 0 /* if new time less than current for less than 1 second, ignore */ if(timediff < 0 && timediff > (int64_t) -1000000) {