From 31863baee2bfb0bccc0e313b82ebf6a5cee997a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 23 Nov 2022 19:13:51 +0800 Subject: [PATCH] CpuUsage: remove unused code (Windows) --- CMakeLists.txt | 1 - src/detection/cpuUsage/cpuUsage.c | 14 -------------- src/detection/cpuUsage/cpuUsage.h | 5 ----- .../cpuUsage/cpuUsage_nowait_windows.cpp | 18 ------------------ 4 files changed, 38 deletions(-) delete mode 100644 src/detection/cpuUsage/cpuUsage_nowait_windows.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 313d46e25..815059e90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -430,7 +430,6 @@ elseif(WIN32) src/detection/bios/bios_windows.c src/detection/board/board_windows.c src/detection/cpu/cpu_windows.c - src/detection/cpuUsage/cpuUsage_nowait_windows.cpp src/detection/cpuUsage/cpuUsage_windows.c src/detection/cursor/cursor_windows.c src/detection/disk/disk_windows.c diff --git a/src/detection/cpuUsage/cpuUsage.c b/src/detection/cpuUsage/cpuUsage.c index 82bf1f7d4..1dbdb4bfb 100644 --- a/src/detection/cpuUsage/cpuUsage.c +++ b/src/detection/cpuUsage/cpuUsage.c @@ -1,18 +1,6 @@ #include "fastfetch.h" #include "cpuUsage.h" -#if FF_DETECTION_CPUUSAGE_NOWAIT - -const char* ffGetCpuUsageResultNoWait(double* result); - -void ffPrepareCPUUsage() {} - -const char* ffGetCpuUsageResult(double* result) { - return ffGetCpuUsageResultNoWait(result); -} - -#else //FF_DETECTION_CPUUSAGE_NOWAIT - #include "common/time.h" #include @@ -61,5 +49,3 @@ const char* ffGetCpuUsageResult(double* result) ffTimeSleep(250); } } - -#endif //FF_DETECTION_CPUUSAGE_NOWAIT diff --git a/src/detection/cpuUsage/cpuUsage.h b/src/detection/cpuUsage/cpuUsage.h index 126fc1a8e..250b30570 100644 --- a/src/detection/cpuUsage/cpuUsage.h +++ b/src/detection/cpuUsage/cpuUsage.h @@ -3,11 +3,6 @@ #ifndef FF_INCLUDED_detection_cpu_cpuUsage #define FF_INCLUDED_detection_cpu_cpuUsage -#ifdef _WIN32 - // Disabled by default because the result does need some time to generate - #define FF_DETECTION_CPUUSAGE_NOWAIT 0 -#endif - const char* ffGetCpuUsageResult(double* result); #endif diff --git a/src/detection/cpuUsage/cpuUsage_nowait_windows.cpp b/src/detection/cpuUsage/cpuUsage_nowait_windows.cpp deleted file mode 100644 index 7ef1aa855..000000000 --- a/src/detection/cpuUsage/cpuUsage_nowait_windows.cpp +++ /dev/null @@ -1,18 +0,0 @@ -extern "C" { -#include "cpuUsage.h" -} -#include "util/windows/wmi.hpp" - -extern "C" const char* ffGetCpuUsageResultNoWait(double* result) -{ - FFWmiQuery query(L"SELECT LoadPercentage FROM Win32_Processor"); - if(!query) - return "Query WMI service failed"; - - if(FFWmiRecord record = query.next()) - record.getReal(L"LoadPercentage", result); - else - return "No WMI result returned"; - - return nullptr; -}