diff options
author | arjan <arjan@arjan-desktop.localdomain> | 2010-09-08 06:02:08 -0700 |
---|---|---|
committer | arjan <arjan@arjan-desktop.localdomain> | 2010-09-08 06:02:08 -0700 |
commit | a842b757b6aa0bede71d3e36c9d86a48c19e481e (patch) | |
tree | e4b21772f58faf259f0241a0c7624b7c673ed25e /devices/ahci.cpp | |
parent | 38d91447b0c19db89673e31655721f8cf6038c3e (diff) | |
download | powertop-a842b757b6aa0bede71d3e36c9d86a48c19e481e.tar.gz |
deal with overflow much better
Diffstat (limited to 'devices/ahci.cpp')
-rw-r--r-- | devices/ahci.cpp | 7 |
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; } |