aboutsummaryrefslogtreecommitdiff
path: root/cpuinf.lua
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2009-10-26 20:32:48 +0100
committerAdrian C. (anrxc) <anrxc@sysphere.org>2009-10-26 20:32:48 +0100
commit0d73f6d8ae32f1cd48ce9f089b902eb0877605e1 (patch)
tree80d41d5fb6095610c781d47fa1a34e91cf184ce3 /cpuinf.lua
parentb105ae21cd47682a4e426604cb15ee6c11aea201 (diff)
downloadvicious-legacy-0d73f6d8ae32f1cd48ce9f089b902eb0877605e1.tar.xz
Ensure returned numbers are of type number
Thanks to Felix for bringing this to my attention. Obviously there was already a safety net for feeding progressbars and graphs... and while this makes for a good coding practice it's not a big deal. We have widgets of type textbox for one, and a lot of string concatenation happens. Strings are formatted, markup is applied...
Diffstat (limited to 'cpuinf.lua')
-rw-r--r--cpuinf.lua8
1 files changed, 4 insertions, 4 deletions
diff --git a/cpuinf.lua b/cpuinf.lua
index 9d1e7c1..d9cd786 100644
--- a/cpuinf.lua
+++ b/cpuinf.lua
@@ -26,13 +26,13 @@ local function worker(format)
if string.match(line, "^processor.*") then
cpu_id = string.match(line, "([%d]+)")
elseif string.match(line, "^cpu MHz.*") then
- local cpu_speed = string.match(line, "([%d]+)%.")
+ local cpu_speed = tonumber(string.match(line, "([%d]+)%."))
cpu_info["{cpu"..cpu_id.." mhz}"] = cpu_speed
- cpu_info["{cpu"..cpu_id.." ghz}"] = tonumber(cpu_speed) / 1000
+ cpu_info["{cpu"..cpu_id.." ghz}"] = cpu_speed / 1000
elseif string.match(line, "^cache size.*") then
- local cpu_cache = string.match(line, "([%d]+)[%s]KB")
+ local cpu_cache = tonumber(string.match(line, "([%d]+)[%s]KB"))
cpu_info["{cpu"..cpu_id.." kb}"] = cpu_cache
- cpu_info["{cpu"..cpu_id.." mb}"] = tonumber(cpu_cache) / 1024
+ cpu_info["{cpu"..cpu_id.." mb}"] = cpu_cache / 1024
end
end
f:close()