From 98ee36e3589be61365fc85d1204a8427580b9832 Mon Sep 17 00:00:00 2001 From: Milind Murhekar Date: Tue, 13 Nov 2018 16:55:29 +0530 Subject: [PATCH] [Fix] Use localtime_r() instead of localtime() Description: This patch fixes the DF180802-00045 issue. Change-Id: I78529e672a2f9504168ed98069d8f00b1ededbcc Signed-off-by: Milind Murhekar --- src/monitor/stc-time.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/monitor/stc-time.c b/src/monitor/stc-time.c index 81e7a0f..1f30f96 100644 --- a/src/monitor/stc-time.c +++ b/src/monitor/stc-time.c @@ -36,21 +36,22 @@ time_t stc_time_get_day_start(time_t now) time_t stc_time_get_week_start(time_t now) { - struct tm *curr; + struct tm curr; + struct tm *res; int days; - curr = localtime(&now); + res = localtime_r(&now, &curr); - curr->tm_sec = 0; - curr->tm_min = 0; - curr->tm_hour = 0; + curr.tm_sec = 0; + curr.tm_min = 0; + curr.tm_hour = 0; - if (curr->tm_wday > 1) - days = curr->tm_wday - 1; + if (curr.tm_wday > 1) + days = curr.tm_wday - 1; else - days = 1 - curr->tm_wday; + days = 1 - curr.tm_wday; - return (mktime(curr) - (days * SEC_IN_DAY)); + return (mktime(&curr) - (days * SEC_IN_DAY)); } time_t stc_time_get_month_start(time_t now, int month_start_date) -- 2.7.4