kernel: usage: fix unused-variable warning when THREAD_USAGE_ALL=n With CONFIG_SCHED_THREAD_USAGE_ANALYSIS=y and CONFIG_SCHED_THREAD_USAGE_ALL=n, sched_cpu_update_usage() is a no-op macro, so the cycles local in k_thread_runtime_stats_enable() and z_thread_stats_reset() is set but never read, triggering a compiler warning. Pass the expression straight to the macro to keep that configuration warning-free. Signed-off-by: Yiren Guo <guoyr_2013@hotmail.com>
diff --git a/kernel/usage.c b/kernel/usage.c index 750f1ab..86fcdeb 100644 --- a/kernel/usage.c +++ b/kernel/usage.c
@@ -260,9 +260,8 @@ if (thread == cpu->current) { uint32_t now = usage_now(); - uint32_t cycles = now - cpu->usage0; - sched_cpu_update_usage(cpu, cycles); + sched_cpu_update_usage(cpu, now - cpu->usage0); cpu->usage0 = now; } @@ -436,9 +435,8 @@ /* Update the current CPU stats. */ uint32_t now = usage_now(); - uint32_t cycles = now - _current_cpu->usage0; - sched_cpu_update_usage(_current_cpu, cycles); + sched_cpu_update_usage(_current_cpu, now - _current_cpu->usage0); _current_cpu->usage0 = now;