diff options
| author | Brad King <brad.king@kitware.com> | 2020-11-24 13:39:59 (GMT) |
|---|---|---|
| committer | Kitware Robot <kwrobot@kitware.com> | 2020-11-24 13:40:08 (GMT) |
| commit | 2ca901637667ff7ab3eee8546d3f129cb0f492bd (patch) | |
| tree | 58238b60189abd7244c5cb32f957f63f7d866cb8 /Source/cmFileTime.cxx | |
| parent | d1b6879ececa9fd24d346ddb6c3474cada9f1823 (diff) | |
| parent | b4c994f69c6e62ab95a5746db237d0237bc87bc1 (diff) | |
| download | CMake-2ca901637667ff7ab3eee8546d3f129cb0f492bd.zip CMake-2ca901637667ff7ab3eee8546d3f129cb0f492bd.tar.gz CMake-2ca901637667ff7ab3eee8546d3f129cb0f492bd.tar.bz2 | |
Merge topic 'cmFileTime-fix-overflow' into release-3.19
b4c994f69c cmFileTime: Fix overflow on time computation
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5526
Diffstat (limited to 'Source/cmFileTime.cxx')
| -rw-r--r-- | Source/cmFileTime.cxx | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Source/cmFileTime.cxx b/Source/cmFileTime.cxx index 96c70fe..0606baf 100644 --- a/Source/cmFileTime.cxx +++ b/Source/cmFileTime.cxx @@ -24,13 +24,13 @@ bool cmFileTime::Load(std::string const& fileName) } # if CMake_STAT_HAS_ST_MTIM // Nanosecond resolution - this->NS = fst.st_mtim.tv_sec * NsPerS + fst.st_mtim.tv_nsec; + this->Time = fst.st_mtim.tv_sec * UtPerS + fst.st_mtim.tv_nsec; # elif CMake_STAT_HAS_ST_MTIMESPEC // Nanosecond resolution - this->NS = fst.st_mtimespec.tv_sec * NsPerS + fst.st_mtimespec.tv_nsec; + this->Time = fst.st_mtimespec.tv_sec * UtPerS + fst.st_mtimespec.tv_nsec; # else // Second resolution - this->NS = fst.st_mtime * NsPerS; + this->Time = fst.st_mtime * UtPerS; # endif #else // Windows version. Get the modification time from extended file attributes. @@ -41,10 +41,11 @@ bool cmFileTime::Load(std::string const& fileName) } // Copy the file time to the output location. - this->NS = (static_cast<NSC>(fdata.ftLastWriteTime.dwHighDateTime) << 32) | - static_cast<NSC>(fdata.ftLastWriteTime.dwLowDateTime); - // The file time resolution is 100 ns. - this->NS *= 100; + using uint64 = unsigned long long; + + this->Time = static_cast<TimeType>( + (uint64(fdata.ftLastWriteTime.dwHighDateTime) << 32) + + fdata.ftLastWriteTime.dwLowDateTime); #endif return true; } |
