aboutsummaryrefslogtreecommitdiff
path: root/widgets
diff options
context:
space:
mode:
authorJoerg T. (Mic92) <jthalheim@gmail.com>2011-09-18 12:59:33 +0200
committerAdrian C. (anrxc) <anrxc@sysphere.org>2011-09-24 17:43:27 +0200
commiteeb27a29166ba30d84a4044fd7ce1acbfa93cadc (patch)
tree10fd27465ac63d2c0745e1dea773f2a64847e4d5 /widgets
parent059442d03931ad30f845d62b789885be7de5b79c (diff)
downloadvicious-legacy-eeb27a29166ba30d84a4044fd7ce1acbfa93cadc.tar.xz
[cpu] fix division by zero
In rare cases diff_total seems to become 0.
Diffstat (limited to 'widgets')
-rw-r--r--widgets/cpu.lua2
1 files changed, 2 insertions, 0 deletions
diff --git a/widgets/cpu.lua b/widgets/cpu.lua
index 978b5f4..86a3e85 100644
--- a/widgets/cpu.lua
+++ b/widgets/cpu.lua
@@ -61,6 +61,8 @@ local function worker(format)
-- Calculate percentage
local diff_total = total_new - cpu_total[i]
local diff_active = active_new - cpu_active[i]
+
+ if diff_total == 0 then diff_total = 1E-6 end
cpu_usage[i] = math.floor((diff_active / diff_total) * 100)
-- Store totals