[presubmit] Enable runtime/threadsafe_fn linter checking.
authormstarzinger <mstarzinger@chromium.org>
Fri, 25 Sep 2015 11:32:38 +0000 (04:32 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 25 Sep 2015 11:32:48 +0000 (11:32 +0000)
This enables linter checking for "runtime/threadsafe_fn" violations
during presubmit and instead marks the few known exceptions that we
allow explicitly.

R=jochen@chromium.org

Review URL: https://codereview.chromium.org/1369673003

Cr-Commit-Position: refs/heads/master@{#30933}

src/base/platform/platform-aix.cc
src/base/platform/platform-cygwin.cc
src/base/platform/platform-freebsd.cc
src/base/platform/platform-linux.cc
src/base/platform/platform-macos.cc
src/base/platform/platform-openbsd.cc
src/base/platform/platform-posix.cc
src/base/platform/platform-qnx.cc
src/base/platform/platform-solaris.cc
src/base/platform/platform-win32.cc
tools/presubmit.py

index 513f5c8..03e9aa3 100644 (file)
@@ -46,7 +46,7 @@ static inline void* mmapHelper(size_t len, int prot, int flags, int fildes,
 const char* OS::LocalTimezone(double time, TimezoneCache* cache) {
   if (std::isnan(time)) return "";
   time_t tv = static_cast<time_t>(floor(time / msPerSecond));
-  struct tm* t = localtime(&tv);
+  struct tm* t = localtime(&tv);  // NOLINT(runtime/threadsafe_fn)
   if (NULL == t) return "";
   return tzname[0];  // The location of the timezone string on AIX.
 }
@@ -56,7 +56,7 @@ double OS::LocalTimeOffset(TimezoneCache* cache) {
   // On AIX, struct tm does not contain a tm_gmtoff field.
   time_t utc = time(NULL);
   DCHECK(utc != -1);
-  struct tm* loc = localtime(&utc);
+  struct tm* loc = localtime(&utc);  // NOLINT(runtime/threadsafe_fn)
   DCHECK(loc != NULL);
   return static_cast<double>((mktime(loc) - utc) * msPerSecond);
 }
index e09fc68..18f151a 100644 (file)
@@ -29,7 +29,7 @@ namespace base {
 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);
+  struct tm* t = localtime(&tv);  // NOLINT(runtime/threadsafe_fn)
   if (NULL == t) return "";
   return tzname[0];  // The location of the timezone string on Cygwin.
 }
@@ -39,7 +39,7 @@ double OS::LocalTimeOffset(TimezoneCache* cache) {
   // On Cygwin, struct tm does not contain a tm_gmtoff field.
   time_t utc = time(NULL);
   DCHECK(utc != -1);
-  struct tm* loc = localtime(&utc);
+  struct tm* loc = localtime(&utc);  // NOLINT(runtime/threadsafe_fn)
   DCHECK(loc != NULL);
   // time - localtime includes any daylight savings offset, so subtract it.
   return static_cast<double>((mktime(loc) - utc) * msPerSecond -
index 3b8f3db..b279e0c 100644 (file)
@@ -39,7 +39,7 @@ namespace base {
 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);
+  struct tm* t = localtime(&tv);  // NOLINT(runtime/threadsafe_fn)
   if (NULL == t) return "";
   return t->tm_zone;
 }
@@ -47,7 +47,7 @@ const char* OS::LocalTimezone(double time, TimezoneCache* cache) {
 
 double OS::LocalTimeOffset(TimezoneCache* cache) {
   time_t tv = time(NULL);
-  struct tm* t = localtime(&tv);
+  struct tm* t = localtime(&tv);  // NOLINT(runtime/threadsafe_fn)
   // 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));
index e2c321c..2a2abfe 100644 (file)
@@ -108,7 +108,7 @@ const char* OS::LocalTimezone(double time, TimezoneCache* cache) {
 #else
   if (std::isnan(time)) return "";
   time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
-  struct tm* t = localtime(&tv);
+  struct tm* t = localtime(&tv);  // NOLINT(runtime/threadsafe_fn)
   if (!t || !t->tm_zone) return "";
   return t->tm_zone;
 #endif
@@ -121,7 +121,7 @@ double OS::LocalTimeOffset(TimezoneCache* cache) {
   return 0;
 #else
   time_t tv = time(NULL);
-  struct tm* t = localtime(&tv);
+  struct tm* t = localtime(&tv);  // NOLINT(runtime/threadsafe_fn)
   // 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));
index 4b760c3..f16f329 100644 (file)
@@ -102,7 +102,7 @@ void OS::SignalCodeMovingGC() {
 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);
+  struct tm* t = localtime(&tv);  // NOLINT(runtime/threadsafe_fn)
   if (NULL == t) return "";
   return t->tm_zone;
 }
@@ -110,7 +110,7 @@ const char* OS::LocalTimezone(double time, TimezoneCache* cache) {
 
 double OS::LocalTimeOffset(TimezoneCache* cache) {
   time_t tv = time(NULL);
-  struct tm* t = localtime(&tv);
+  struct tm* t = localtime(&tv);  // NOLINT(runtime/threadsafe_fn)
   // 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));
index e5b159b..369dd8e 100644 (file)
@@ -37,7 +37,7 @@ namespace base {
 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);
+  struct tm* t = localtime(&tv);  // NOLINT(runtime/threadsafe_fn)
   if (NULL == t) return "";
   return t->tm_zone;
 }
@@ -45,7 +45,7 @@ const char* OS::LocalTimezone(double time, TimezoneCache* cache) {
 
 double OS::LocalTimeOffset(TimezoneCache* cache) {
   time_t tv = time(NULL);
-  struct tm* t = localtime(&tv);
+  struct tm* t = localtime(&tv);  // NOLINT(runtime/threadsafe_fn)
   // 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));
index 8a037c0..046dbb6 100644 (file)
@@ -384,7 +384,7 @@ void OS::ClearTimezoneCache(TimezoneCache* cache) {
 double OS::DaylightSavingsOffset(double time, TimezoneCache*) {
   if (std::isnan(time)) return std::numeric_limits<double>::quiet_NaN();
   time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
-  struct tm* t = localtime(&tv);
+  struct tm* t = localtime(&tv);  // NOLINT(runtime/threadsafe_fn)
   if (NULL == t) return std::numeric_limits<double>::quiet_NaN();
   return t->tm_isdst > 0 ? 3600 * msPerSecond : 0;
 }
index 04ca665..b166528 100644 (file)
@@ -88,7 +88,7 @@ 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);
+  struct tm* t = localtime(&tv);  // NOLINT(runtime/threadsafe_fn)
   if (NULL == t) return "";
   return t->tm_zone;
 }
@@ -96,7 +96,7 @@ const char* OS::LocalTimezone(double time, TimezoneCache* cache) {
 
 double OS::LocalTimeOffset(TimezoneCache* cache) {
   time_t tv = time(NULL);
-  struct tm* t = localtime(&tv);
+  struct tm* t = localtime(&tv);  // NOLINT(runtime/threadsafe_fn)
   // 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));
index e844aa1..7e07f1a 100644 (file)
@@ -38,7 +38,7 @@ namespace base {
 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);
+  struct tm* t = localtime(&tv);  // NOLINT(runtime/threadsafe_fn)
   if (NULL == t) return "";
   return tzname[0];  // The location of the timezone string on Solaris.
 }
index afd3061..a73dc52 100644 (file)
@@ -46,7 +46,7 @@ inline void MemoryBarrier() {
 
 
 int localtime_s(tm* out_tm, const time_t* time) {
-  tm* posix_local_time_struct = localtime(time);
+  tm* posix_local_time_struct = localtime(time);  // NOLINT
   if (posix_local_time_struct == NULL) return 1;
   *out_tm = *posix_local_time_struct;
   return 0;
index c11e89d..604e65b 100755 (executable)
@@ -63,7 +63,6 @@ LINT_RULES = """
 -readability/nolint
 +readability/streams
 -runtime/references
--runtime/threadsafe_fn
 -whitespace/semicolon
 """.split()