summaryrefslogtreecommitdiff
path: root/libartbase/base/time_utils.cc
diff options
context:
space:
mode:
author Hans Boehm <hboehm@google.com> 2020-08-26 21:41:13 -0700
committer Hans Boehm <hboehm@google.com> 2020-08-28 15:47:40 +0000
commitca8343842f9094fd5eb86569d293250e783f582c (patch)
treec4e040eff9f8528626535106a88fe4e7bb317a00 /libartbase/base/time_utils.cc
parent49a19f38c35605e675eee271691ed465802859bf (diff)
Avoid NanoSleep overflow
NanoSleep with a very large argument could cause it to fail on 32 bits. It doesn't appear to me that this was ever exposed to client code. So this was probably not an observable bug. Remove redundant uses of "constexpr inline" instead of adding another one. Bug: 161006928 Test: Treehugger Change-Id: I2ad3b92d01c764915ab2aac17cc72ac5c6907ed4
Diffstat (limited to 'libartbase/base/time_utils.cc')
-rw-r--r--libartbase/base/time_utils.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/libartbase/base/time_utils.cc b/libartbase/base/time_utils.cc
index d38d885f5d..037d7b59a3 100644
--- a/libartbase/base/time_utils.cc
+++ b/libartbase/base/time_utils.cc
@@ -216,7 +216,7 @@ uint64_t ProcessCpuNanoTime() {
void NanoSleep(uint64_t ns) {
timespec tm;
- tm.tv_sec = ns / MsToNs(1000);
+ tm.tv_sec = SaturatedTimeT(ns / MsToNs(1000));
tm.tv_nsec = ns - static_cast<uint64_t>(tm.tv_sec) * MsToNs(1000);
nanosleep(&tm, nullptr);
}