Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: src/base/platform/platform-qnx.cc

Issue 2184673002: [base] Use thread safe localtime_r() instead of localtime(). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/base/platform/platform-posix.cc ('k') | src/base/platform/platform-solaris.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/base/platform/platform-qnx.cc
diff --git a/src/base/platform/platform-qnx.cc b/src/base/platform/platform-qnx.cc
index 3c904676273d76526543a787d9e6f1444206220e..6ff953d65cda0d423c06880c7e7255cd3f8efe42 100644
--- a/src/base/platform/platform-qnx.cc
+++ b/src/base/platform/platform-qnx.cc
@@ -88,7 +88,8 @@ bool OS::ArmUsingHardFloat() {
const char* OS::LocalTimezone(double time, TimezoneCache* cache) {
if (std::isnan(time)) return "";
time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
- struct tm* t = localtime(&tv); // NOLINT(runtime/threadsafe_fn)
+ struct tm tm;
+ struct tm* t = localtime_r(&tv, &tm);
if (NULL == t) return "";
return t->tm_zone;
}
@@ -96,7 +97,8 @@ const char* OS::LocalTimezone(double time, TimezoneCache* cache) {
double OS::LocalTimeOffset(TimezoneCache* cache) {
time_t tv = time(NULL);
- struct tm* t = localtime(&tv); // NOLINT(runtime/threadsafe_fn)
+ struct tm tm;
+ struct tm* t = localtime_r(&tv, &tm);
// tm_gmtoff includes any daylight savings offset, so subtract it.
return static_cast<double>(t->tm_gmtoff * msPerSecond -
(t->tm_isdst > 0 ? 3600 * msPerSecond : 0));
« no previous file with comments | « src/base/platform/platform-posix.cc ('k') | src/base/platform/platform-solaris.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698