From 6ec34c7cb3fc8f9d8fdde7e3e673da15b7ce7912 Mon Sep 17 00:00:00 2001 From: mstarzinger Date: Fri, 25 Sep 2015 04:32:38 -0700 Subject: [PATCH] [presubmit] Enable runtime/threadsafe_fn linter checking. 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 | 4 ++-- src/base/platform/platform-cygwin.cc | 4 ++-- src/base/platform/platform-freebsd.cc | 4 ++-- src/base/platform/platform-linux.cc | 4 ++-- src/base/platform/platform-macos.cc | 4 ++-- src/base/platform/platform-openbsd.cc | 4 ++-- src/base/platform/platform-posix.cc | 2 +- src/base/platform/platform-qnx.cc | 4 ++-- src/base/platform/platform-solaris.cc | 2 +- src/base/platform/platform-win32.cc | 2 +- tools/presubmit.py | 1 - 11 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/base/platform/platform-aix.cc b/src/base/platform/platform-aix.cc index 513f5c8..03e9aa3 100644 --- a/src/base/platform/platform-aix.cc +++ b/src/base/platform/platform-aix.cc @@ -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(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((mktime(loc) - utc) * msPerSecond); } diff --git a/src/base/platform/platform-cygwin.cc b/src/base/platform/platform-cygwin.cc index e09fc68..18f151a 100644 --- a/src/base/platform/platform-cygwin.cc +++ b/src/base/platform/platform-cygwin.cc @@ -29,7 +29,7 @@ namespace base { const char* OS::LocalTimezone(double time, TimezoneCache* cache) { if (std::isnan(time)) return ""; time_t tv = static_cast(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((mktime(loc) - utc) * msPerSecond - diff --git a/src/base/platform/platform-freebsd.cc b/src/base/platform/platform-freebsd.cc index 3b8f3db..b279e0c 100644 --- a/src/base/platform/platform-freebsd.cc +++ b/src/base/platform/platform-freebsd.cc @@ -39,7 +39,7 @@ namespace base { const char* OS::LocalTimezone(double time, TimezoneCache* cache) { if (std::isnan(time)) return ""; time_t tv = static_cast(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(t->tm_gmtoff * msPerSecond - (t->tm_isdst > 0 ? 3600 * msPerSecond : 0)); diff --git a/src/base/platform/platform-linux.cc b/src/base/platform/platform-linux.cc index e2c321c..2a2abfe 100644 --- a/src/base/platform/platform-linux.cc +++ b/src/base/platform/platform-linux.cc @@ -108,7 +108,7 @@ const char* OS::LocalTimezone(double time, TimezoneCache* cache) { #else if (std::isnan(time)) return ""; time_t tv = static_cast(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(t->tm_gmtoff * msPerSecond - (t->tm_isdst > 0 ? 3600 * msPerSecond : 0)); diff --git a/src/base/platform/platform-macos.cc b/src/base/platform/platform-macos.cc index 4b760c3..f16f329 100644 --- a/src/base/platform/platform-macos.cc +++ b/src/base/platform/platform-macos.cc @@ -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(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(t->tm_gmtoff * msPerSecond - (t->tm_isdst > 0 ? 3600 * msPerSecond : 0)); diff --git a/src/base/platform/platform-openbsd.cc b/src/base/platform/platform-openbsd.cc index e5b159b..369dd8e 100644 --- a/src/base/platform/platform-openbsd.cc +++ b/src/base/platform/platform-openbsd.cc @@ -37,7 +37,7 @@ namespace base { const char* OS::LocalTimezone(double time, TimezoneCache* cache) { if (std::isnan(time)) return ""; time_t tv = static_cast(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(t->tm_gmtoff * msPerSecond - (t->tm_isdst > 0 ? 3600 * msPerSecond : 0)); diff --git a/src/base/platform/platform-posix.cc b/src/base/platform/platform-posix.cc index 8a037c0..046dbb6 100644 --- a/src/base/platform/platform-posix.cc +++ b/src/base/platform/platform-posix.cc @@ -384,7 +384,7 @@ void OS::ClearTimezoneCache(TimezoneCache* cache) { double OS::DaylightSavingsOffset(double time, TimezoneCache*) { if (std::isnan(time)) return std::numeric_limits::quiet_NaN(); time_t tv = static_cast(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::quiet_NaN(); return t->tm_isdst > 0 ? 3600 * msPerSecond : 0; } diff --git a/src/base/platform/platform-qnx.cc b/src/base/platform/platform-qnx.cc index 04ca665..b166528 100644 --- a/src/base/platform/platform-qnx.cc +++ b/src/base/platform/platform-qnx.cc @@ -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(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(t->tm_gmtoff * msPerSecond - (t->tm_isdst > 0 ? 3600 * msPerSecond : 0)); diff --git a/src/base/platform/platform-solaris.cc b/src/base/platform/platform-solaris.cc index e844aa1..7e07f1a 100644 --- a/src/base/platform/platform-solaris.cc +++ b/src/base/platform/platform-solaris.cc @@ -38,7 +38,7 @@ namespace base { const char* OS::LocalTimezone(double time, TimezoneCache* cache) { if (std::isnan(time)) return ""; time_t tv = static_cast(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. } diff --git a/src/base/platform/platform-win32.cc b/src/base/platform/platform-win32.cc index afd3061..a73dc52 100644 --- a/src/base/platform/platform-win32.cc +++ b/src/base/platform/platform-win32.cc @@ -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; diff --git a/tools/presubmit.py b/tools/presubmit.py index c11e89d..604e65b 100755 --- a/tools/presubmit.py +++ b/tools/presubmit.py @@ -63,7 +63,6 @@ LINT_RULES = """ -readability/nolint +readability/streams -runtime/references --runtime/threadsafe_fn -whitespace/semicolon """.split() -- 2.7.4