From patchwork Mon Jul 23 13:02:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1/8] cpu: cpufreq: cpufreq and cpuidle dirs confusing cpuN parsing Date: Mon, 23 Jul 2012 03:02:51 -0000 From: Colin King X-Patchwork-Id: 172663 Message-Id: <1343048578-13332-2-git-send-email-colin.king@canonical.com> To: fwts-devel@lists.ubuntu.com From: Colin Ian King We need to only exercise CPUs in the path /sys/devices/system/cpu when the directory matches cpuN (where N is a number). Add an extra check so we don't get fooled by cpufreq and cpuidle dir names in /sys/devices/system/cpu Signed-off-by: Colin Ian King Acked-by: Keng-Yu Lin Acked-by: Ivan Hu --- src/cpu/cpufreq/cpufreq.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c index d2c5281..a141812 100644 --- a/src/cpu/cpufreq/cpufreq.c +++ b/src/cpu/cpufreq/cpufreq.c @@ -36,6 +36,7 @@ #include #include #include +#include #define FWTS_CPU_PATH "/sys/devices/system/cpu" @@ -626,7 +627,7 @@ static int cpufreq_test1(fwts_framework *fw) } while ((entry = readdir(dir)) != NULL) { - if (entry && strlen(entry->d_name)>3) { + if (entry && strlen(entry->d_name)>3 && isdigit(entry->d_name[3])) { cpu = strtoul(entry->d_name+3,NULL,10); lowest_speed(fw, cpu); } @@ -636,7 +637,7 @@ static int cpufreq_test1(fwts_framework *fw) /* then do the benchmark */ while ((entry = readdir(dir)) != NULL) { - if (entry && strlen(entry->d_name)>3) { + if (entry && strlen(entry->d_name)>3 && isdigit(entry->d_name[3])) { cpu = strtoul(entry->d_name+3,NULL,10); do_cpu(fw, cpu); lowest_speed(fw, cpu); @@ -649,7 +650,7 @@ static int cpufreq_test1(fwts_framework *fw) /* set everything back to the highest speed again */ while ((entry = readdir(dir)) != NULL) { - if (entry && strlen(entry->d_name)>3) { + if (entry && strlen(entry->d_name)>3 && isdigit(entry->d_name[3])) { cpu = strtoul(entry->d_name+3,NULL,10); highest_speed(fw, cpu); }