[PATCH 1/8] cpu: cpufreq: cpufreq and cpuidle dirs confusing cpuN parsing

IvanHu ivan.hu at canonical.com
Wed Jul 25 08:01:34 UTC 2012


On 07/23/2012 09:02 PM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> 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 <colin.king at canonical.com>
> ---
>   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 <sched.h>
>   #include <time.h>
>   #include <math.h>
> +#include <ctype.h>
>
>   #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);
>   		}
>

Acked-by: Ivan Hu <ivan.hu at canonical.com>



More information about the fwts-devel mailing list