From 9bf2b34bb922dca0e7ed5c007353f506240806f3 Mon Sep 17 00:00:00 2001
From: Palmer Cox
Date: Tue, 27 Nov 2012 13:17:45 +0100
Subject: [PATCH] --- yaml --- r: 336754 b: refs/heads/master c:
53d2000ebe0618219f73ac866701533237180044 h: refs/heads/master v: v3
---
[refs] | 2 +-
.../power/cpupower/utils/helpers/topology.c | 21 ++++++++++++-------
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/[refs] b/[refs]
index 0016afc5fb17..8d83407bb98d 100644
--- a/[refs]
+++ b/[refs]
@@ -1,2 +1,2 @@
---
-refs/heads/master: fb8eaeb7ab96b09c910e36abf7df7f9ecbb0fb60
+refs/heads/master: 53d2000ebe0618219f73ac866701533237180044
diff --git a/trunk/tools/power/cpupower/utils/helpers/topology.c b/trunk/tools/power/cpupower/utils/helpers/topology.c
index 4eae2c47ba48..216f3e3466ce 100644
--- a/trunk/tools/power/cpupower/utils/helpers/topology.c
+++ b/trunk/tools/power/cpupower/utils/helpers/topology.c
@@ -20,9 +20,8 @@
#include
/* returns -1 on failure, 0 on success */
-int sysfs_topology_read_file(unsigned int cpu, const char *fname)
+static int sysfs_topology_read_file(unsigned int cpu, const char *fname, int *result)
{
- unsigned long value;
char linebuf[MAX_LINE_LEN];
char *endp;
char path[SYSFS_PATH_MAX];
@@ -31,10 +30,10 @@ int sysfs_topology_read_file(unsigned int cpu, const char *fname)
cpu, fname);
if (sysfs_read_file(path, linebuf, MAX_LINE_LEN) == 0)
return -1;
- value = strtoul(linebuf, &endp, 0);
+ *result = strtol(linebuf, &endp, 0);
if (endp == linebuf || errno == ERANGE)
return -1;
- return value;
+ return 0;
}
struct cpuid_core_info {
@@ -82,13 +81,19 @@ int get_cpu_topology(struct cpupower_topology *cpu_top)
for (cpu = 0; cpu < cpus; cpu++) {
cpu_top->core_info[cpu].cpu = cpu;
cpu_top->core_info[cpu].is_online = sysfs_is_cpu_online(cpu);
- cpu_top->core_info[cpu].pkg =
- sysfs_topology_read_file(cpu, "physical_package_id");
+ if(sysfs_topology_read_file(
+ cpu,
+ "physical_package_id",
+ &(cpu_top->core_info[cpu].pkg)) < 0)
+ return -1;
if ((int)cpu_top->core_info[cpu].pkg != -1 &&
cpu_top->core_info[cpu].pkg > cpu_top->pkgs)
cpu_top->pkgs = cpu_top->core_info[cpu].pkg;
- cpu_top->core_info[cpu].core =
- sysfs_topology_read_file(cpu, "core_id");
+ if(sysfs_topology_read_file(
+ cpu,
+ "core_id",
+ &(cpu_top->core_info[cpu].core)) < 0)
+ return -1;
}
cpu_top->pkgs++;