From 0d73f6d8ae32f1cd48ce9f089b902eb0877605e1 Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Mon, 26 Oct 2009 20:32:48 +0100 Subject: 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... --- cpufreq.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cpufreq.lua') diff --git a/cpufreq.lua b/cpufreq.lua index 0acc304..436e48b 100644 --- a/cpufreq.lua +++ b/cpufreq.lua @@ -4,6 +4,7 @@ --------------------------------------------------- -- {{{ Grab environment +local tonumber = tonumber local io = { open = io.open } local setmetatable = setmetatable local string = { @@ -45,7 +46,7 @@ local function worker(format, cpuid) local f = io.open("/sys/devices/system/cpu/"..cpuid.."/cpufreq/scaling_voltages") if f then for line in f:lines() do if string.find(line, "^"..freq) then - voltage.mv = string.match(line, "[%d]+[%s]([%d]+)") + voltage.mv = tonumber(string.match(line, "[%d]+[%s]([%d]+)")) break end end -- cgit v1.2.3