aboutsummaryrefslogtreecommitdiff
path: root/devices/ahci.cpp
diff options
context:
space:
mode:
authorarjan <arjan@arjan-desktop.localdomain>2010-09-08 06:02:08 -0700
committerarjan <arjan@arjan-desktop.localdomain>2010-09-08 06:02:08 -0700
commita842b757b6aa0bede71d3e36c9d86a48c19e481e (patch)
treee4b21772f58faf259f0241a0c7624b7c673ed25e /devices/ahci.cpp
parent38d91447b0c19db89673e31655721f8cf6038c3e (diff)
downloadpowertop-a842b757b6aa0bede71d3e36c9d86a48c19e481e.tar.gz
deal with overflow much better
Diffstat (limited to 'devices/ahci.cpp')
-rw-r--r--devices/ahci.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/devices/ahci.cpp b/devices/ahci.cpp
index 1309a28..3ed5455 100644
--- a/devices/ahci.cpp
+++ b/devices/ahci.cpp
@@ -89,10 +89,14 @@ void ahci::end_measurement(void)
}
p = (end_active - start_active) / (0.001 + end_active + end_partial + end_slumber - start_active - start_partial - start_slumber) * 100.0;
+ if (p < 0)
+ p = 0;
sprintf(powername, "%s-active", name);
report_utilization(powername, p);
p = (end_partial - start_partial) / (0.001 + end_active + end_partial + end_slumber - start_active - start_partial - start_slumber) * 100.0;
+ if (p < 0)
+ p = 0;
sprintf(powername, "%s-partial", name);
report_utilization(powername, p);
}
@@ -104,6 +108,9 @@ double ahci::utilization(void)
p = (end_partial - start_partial + end_active - start_active) / (0.001 + end_active + end_partial + end_slumber - start_active - start_partial - start_slumber) * 100.0;
+ if (p < 0)
+ p = 0;
+
return p;
}