powertop/powertop-1.98-unknown-readings-fix.patch
2012-02-06 14:55:14 +00:00

36 lines
978 B
Diff

diff -up powertop-1.98/measurement/acpi.cpp.orig powertop-1.98/measurement/acpi.cpp
--- powertop-1.98/measurement/acpi.cpp.orig 2011-05-11 06:48:37.000000000 +0200
+++ powertop-1.98/measurement/acpi.cpp 2012-01-10 18:31:21.093799991 +0100
@@ -108,8 +108,13 @@ void acpi_power_meter::measure(void)
while (*c == ' ') c++;
_capacity = strtoull(c, NULL, 10);
c = strchr(c, ' ');
- c++;
- strcpy(capacity_units, c);
+ if (c) {
+ c++;
+ strcpy(capacity_units, c);
+ } else {
+ _capacity = 0;
+ strcpy(capacity_units, "Unknown");
+ }
}
if (strstr(line, "present voltage:")) {
c = strchr(line, ':');
@@ -117,8 +122,13 @@ void acpi_power_meter::measure(void)
while (*c == ' ') c++;
_voltage = strtoull(c, NULL, 10);
c = strchr(c, ' ');
- c++;
- strcpy(voltage_units, c);
+ if (c) {
+ c++;
+ strcpy(voltage_units, c);
+ } else {
+ _voltage = 0;
+ strcpy(voltage_units, "Unknown");
+ }
}
}
file.close();