From 1b3d713e5049d0cd1156840d625eba275a4e0b5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 1 Nov 2023 15:36:13 +0800 Subject: [PATCH] CPUUsage: always print something --- src/common/bar.c | 4 +++- src/detection/cpuusage/cpuusage.c | 11 ++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/common/bar.c b/src/common/bar.c index 4bd6e76ba..558f5d542 100644 --- a/src/common/bar.c +++ b/src/common/bar.c @@ -78,7 +78,9 @@ void ffAppendPercentNum(FFstrbuf* buffer, double percent, uint8_t green, uint8_t if (colored && !options->pipe) { - if(green < yellow) + if(percent != percent) + ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_BLACK "m"); + else if(green < yellow) { if (percent <= green) ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_GREEN "m"); diff --git a/src/detection/cpuusage/cpuusage.c b/src/detection/cpuusage/cpuusage.c index 255ee0fed..292a91a28 100644 --- a/src/detection/cpuusage/cpuusage.c +++ b/src/detection/cpuusage/cpuusage.c @@ -40,11 +40,12 @@ retry: FFCpuUsageInfo* cpuTime2 = ffListGet(&cpuTimes2, i); if (cpuTime2->totalAll <= cpuTime1->totalAll) { - ffListClear(&cpuTimes2); - ffTimeSleep(200); - if (++retryCount >= 10) - return "Retry count exceeded"; - goto retry; + if (++retryCount <= 3) + { + ffListClear(&cpuTimes2); + ffTimeSleep(200); + goto retry; + } } }