From d711b97aa54eba45e9f6d3d827f063aaba98b5b0 Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Sun, 24 Mar 2019 16:15:09 +0800 Subject: [PATCH] src: apply clang-tidy rule bugprone-incorrect-roundings PR-URL: https://github.com/nodejs/node/pull/26885 Reviewed-By: James M Snell Reviewed-By: Minwoo Jung Reviewed-By: Refael Ackermann --- src/node_platform.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/node_platform.cc b/src/node_platform.cc index 17d71b22945756..47c4373a0f7d6e 100644 --- a/src/node_platform.cc +++ b/src/node_platform.cc @@ -5,6 +5,7 @@ #include "debug_utils.h" #include "util.h" #include +#include #include namespace node { @@ -126,8 +127,7 @@ class WorkerThreadsTaskRunner::DelayedTaskScheduler { delay_in_seconds_(delay_in_seconds) {} void Run() override { - uint64_t delay_millis = - static_cast(delay_in_seconds_ + 0.5) * 1000; + uint64_t delay_millis = llround(delay_in_seconds_ * 1000); std::unique_ptr timer(new uv_timer_t()); CHECK_EQ(0, uv_timer_init(&scheduler_->loop_, timer.get())); timer->data = task_.release(); @@ -387,8 +387,8 @@ bool PerIsolatePlatformData::FlushForegroundTasksInternal() { while (std::unique_ptr delayed = foreground_delayed_tasks_.Pop()) { did_work = true; - uint64_t delay_millis = - static_cast(delayed->timeout + 0.5) * 1000; + uint64_t delay_millis = llround(delayed->timeout * 1000); + delayed->timer.data = static_cast(delayed.get()); uv_timer_init(loop_, &delayed->timer); // Timers may not guarantee queue ordering of events with the same delay if