[PATCH] cpu: cpufreq: initialize online_cpus in for loop
Colin King
colin.king at canonical.com
Tue Jan 19 09:24:08 UTC 2021
From: Colin Ian King <colin.king at canonical.com>
In the case where macro FWTS_ARCH_INTEL is not defined the
function returns early and the initialization of online_cpus
throws a cppcheck style warning because it has been initialized
but has not been used. Move the online_cpus initialization to
the start of the for-loop to clear this warning.
Cleans up cppcheck warning:
src/cpu/cpufreq/cpufreq.c:398:21: style: Variable 'online_cpus'
is assigned a value that is never used. [unreadVariable]
int i, online_cpus = 0;
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
src/cpu/cpufreq/cpufreq.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
index fa0acb16..d72eabb2 100644
--- a/src/cpu/cpufreq/cpufreq.c
+++ b/src/cpu/cpufreq/cpufreq.c
@@ -395,7 +395,7 @@ static int cpufreq_test_cpu_performance(fwts_framework *fw)
static int sw_tests_possible(fwts_framework *fw)
{
- int i, online_cpus = 0;
+ int i, online_cpus;
#ifndef FWTS_ARCH_INTEL
fwts_skipped(fw, "Platform doesn't perform SW_ cpu frequency control");
@@ -408,7 +408,7 @@ static int sw_tests_possible(fwts_framework *fw)
}
/* count the number of CPUs online now */
- for (i = 0; i < num_cpus; i++)
+ for (online_cpus = 0, i = 0; i < num_cpus; i++)
if (cpus[i].online)
online_cpus++;
--
2.29.2
More information about the fwts-devel
mailing list