Merge "[Fix] Use localtime_r() instead of localtime()" into tizen
authorJaehyun Kim <jeik01.kim@samsung.com>
Tue, 20 Nov 2018 04:59:38 +0000 (04:59 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Tue, 20 Nov 2018 04:59:38 +0000 (04:59 +0000)
src/monitor/stc-time.c

index 81e7a0f..1f30f96 100644 (file)
@@ -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)