From f8ea9cd64e05177ce731c835fc0d47903c66dd2e Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Mon, 3 Jan 2022 02:52:02 -0700 Subject: [PATCH] Userland: Resolve unused-but-set-varaible warnings These are almost always bugs, so enable globally. Remove unused counter variables in SystemMonitor and disk_benchmark. --- CMakeLists.txt | 1 - Userland/Applications/SystemMonitor/ProcessModel.cpp | 3 --- Userland/Utilities/disk_benchmark.cpp | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 99464d9f4dc..f321f37a7c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -200,7 +200,6 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang$") add_compile_options(-Wno-implicit-const-int-float-conversion) add_compile_options(-Wno-null-pointer-subtraction) add_compile_options(-Wno-unneeded-internal-declaration) - add_compile_options(-Wno-unused-but-set-variable) add_compile_options(-Wno-unused-const-variable) add_compile_options(-Wno-unused-function) add_compile_options(-Wno-unused-private-field) diff --git a/Userland/Applications/SystemMonitor/ProcessModel.cpp b/Userland/Applications/SystemMonitor/ProcessModel.cpp index b3cefcd4501..d4b5fe87995 100644 --- a/Userland/Applications/SystemMonitor/ProcessModel.cpp +++ b/Userland/Applications/SystemMonitor/ProcessModel.cpp @@ -334,7 +334,6 @@ void ProcessModel::update() auto all_processes = Core::ProcessStatisticsReader::get_all(m_proc_all); HashTable live_tids; - u64 sum_time_scheduled = 0, sum_time_scheduled_kernel = 0; u64 total_time_scheduled_diff = 0; if (all_processes.has_value()) { if (m_has_total_scheduled_time) @@ -382,8 +381,6 @@ void ProcessModel::update() state.cpu_percent = 0; state.priority = thread.priority; state.state = thread.state; - sum_time_scheduled += thread.time_user + thread.time_kernel; - sum_time_scheduled_kernel += thread.time_kernel; auto& thread_data = *m_threads.ensure(thread.tid, [] { return make(); }); thread_data.previous_state = move(thread_data.current_state); thread_data.current_state = move(state); diff --git a/Userland/Utilities/disk_benchmark.cpp b/Userland/Utilities/disk_benchmark.cpp index 5d677b3ed1f..d55c5073c44 100644 --- a/Userland/Utilities/disk_benchmark.cpp +++ b/Userland/Utilities/disk_benchmark.cpp @@ -147,7 +147,7 @@ Optional benchmark(const String& filename, int file_size, int block_size auto timer = Core::ElapsedTimer::start_new(); ssize_t total_written = 0; - for (ssize_t j = 0; j < file_size; j += block_size) { + while (total_written < file_size) { auto nwritten = write(fd, buffer.data(), block_size); if (nwritten < 0) { perror("write");