From 176aec018832154ec043ea4be86f4f36c8269fdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=98=89=E5=AE=9D?= Date: Wed, 7 May 2025 14:54:15 +0800 Subject: [PATCH] modify uint64 --- .../samgr/native/source/collect/common_event_collect.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/services/samgr/native/source/collect/common_event_collect.cpp b/services/samgr/native/source/collect/common_event_collect.cpp index 27879800..0a9707ab 100644 --- a/services/samgr/native/source/collect/common_event_collect.cpp +++ b/services/samgr/native/source/collect/common_event_collect.cpp @@ -789,9 +789,10 @@ float CommonEventCollect::GetCpuUsage(const char* file, uint32_t interval) return CPU_LOAD_INVALID; } - uint64_t totalDelta = total - totalPre; - uint64_t idleDelta = idle - idlePre; - if (totalDelta == 0) { + constexpr uint64_t MAX = std::numeric_limits::max(); + uint64_t totalDelta = (total >= totalPre) ? (total - totalPre) : (MAX - totalPre + total); + uint64_t idleDelta = (idle >= idlePre) ? (idle - idlePre) : (MAX - idlePre + idle); + if (totalDelta == 0 || totalDelta < idleDelta) { return CPU_LOAD_INVALID; } -- Gitee