use localtime_r() instead of localtime()

This commit is contained in:
Andreas Steffen
2009-05-14 13:55:56 +02:00
parent 7eea232f44
commit 6e0ff31e07
+6 -10
View File
@@ -880,22 +880,18 @@ daily_log_reset(void)
void void
daily_log_event(void) daily_log_event(void)
{ {
struct tm *ltime; struct tm lt;
time_t n, interval; time_t t, interval;
/* attempt to schedule oneself to midnight, local time /* attempt to schedule oneself to midnight, local time
* do this by getting seconds in the day, and delaying * do this by getting seconds in the day, and delaying
* by 86400 - hour*3600+minutes*60+seconds. * by 86400 - 3600*hours - 60*minutes - seconds.
*/ */
time(&n); time(&t);
ltime = localtime(&n); localtime_r(&t, &lt);
interval = (24 * 60 * 60) interval = 3600 * (24 - lt.tm_hour) - 60 * lt.tm_min - lt.tm_sec;
- (ltime->tm_sec
+ ltime->tm_min * 60
+ ltime->tm_hour * 3600);
event_schedule(EVENT_LOG_DAILY, interval, NULL); event_schedule(EVENT_LOG_DAILY, interval, NULL);
daily_log_reset(); daily_log_reset();
} }