From b0025409e9e1f7524e94b47a0933d6d8421c42f8 Mon Sep 17 00:00:00 2001 From: shirou Date: Thu, 14 Nov 2019 21:47:42 +0900 Subject: [PATCH] [cpu][linux]: add cpuinfo parse check. --- cpu/cpu_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/cpu_linux.go b/cpu/cpu_linux.go index be98dd7..0b9e9d2 100644 --- a/cpu/cpu_linux.go +++ b/cpu/cpu_linux.go @@ -87,7 +87,7 @@ func finishCPUInfo(c *InfoStat) error { lines, err = common.ReadLines(sysCPUPath(c.CPU, "cpufreq/cpuinfo_max_freq")) // if we encounter errors below such as there are no cpuinfo_max_freq file, // we just ignore. so let Mhz is 0. - if err != nil { + if err != nil || len(lines) == 0 { return nil } value, err = strconv.ParseFloat(lines[0], 64)