pkg/idtools: fix use of bufio.Scanner.Err

The Err() method should be called after the Scan() loop,
not inside it.

Fixes: 9a3ab0358e
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin 2020-03-11 19:16:29 -07:00
parent 5b658a0348
commit 745ed9686b
1 changed files with 2 additions and 5 deletions

View File

@ -236,10 +236,6 @@ func parseSubidFile(path, username string) (ranges, error) {
s := bufio.NewScanner(subidFile)
for s.Scan() {
if err := s.Err(); err != nil {
return rangeList, err
}
text := strings.TrimSpace(s.Text())
if text == "" || strings.HasPrefix(text, "#") {
continue
@ -260,5 +256,6 @@ func parseSubidFile(path, username string) (ranges, error) {
rangeList = append(rangeList, subIDRange{startid, length})
}
}
return rangeList, nil
return rangeList, s.Err()
}