From eeb27a29166ba30d84a4044fd7ce1acbfa93cadc Mon Sep 17 00:00:00 2001 From: "Joerg T. (Mic92)" Date: Sun, 18 Sep 2011 12:59:33 +0200 Subject: [cpu] fix division by zero In rare cases diff_total seems to become 0. --- widgets/cpu.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'widgets') 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 -- cgit v1.2.3