Skip to content

Commit 78592ae

Browse files
committed
parseCPUInfo*: add error checking
In case the input can't be read, scanner.Scan() stops and the code is supposed to check for error using scanner.Err(). Do that. In other words, instead of returning half-read cpuinfo, return an error. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 1de65d4 commit 78592ae

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cpuinfo.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func parseCPUInfoX86(info io.Reader) ([]CPUInfo, error) {
183183
cpuinfo[i].PowerManagement = field[1]
184184
}
185185
}
186-
return cpuinfo, nil
186+
return cpuinfo, scanner.Err()
187187
}
188188

189189
func parseCPUInfoARM(info io.Reader) ([]CPUInfo, error) {
@@ -230,7 +230,7 @@ func parseCPUInfoARM(info io.Reader) ([]CPUInfo, error) {
230230
}
231231
}
232232

233-
return cpuinfo, nil
233+
return cpuinfo, scanner.Err()
234234
}
235235

236236
func parseCPUInfoS390X(info io.Reader) ([]CPUInfo, error) {
@@ -298,7 +298,7 @@ func parseCPUInfoS390X(info io.Reader) ([]CPUInfo, error) {
298298
}
299299
}
300300

301-
return cpuinfo, nil
301+
return cpuinfo, scanner.Err()
302302
}
303303

304304
func parseCPUInfoPPC(info io.Reader) ([]CPUInfo, error) {
@@ -343,7 +343,7 @@ func parseCPUInfoPPC(info io.Reader) ([]CPUInfo, error) {
343343
cpuinfo[i].CPUMHz = v
344344
}
345345
}
346-
return cpuinfo, nil
346+
return cpuinfo, scanner.Err()
347347
}
348348

349349
// firstNonEmptyLine advances the scanner to the first non-empty line

0 commit comments

Comments
 (0)