From 745ed9686b7bf09399aa013236b8112e63722dfe Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 11 Mar 2020 19:16:29 -0700 Subject: [PATCH] pkg/idtools: fix use of bufio.Scanner.Err The Err() method should be called after the Scan() loop, not inside it. Fixes: 9a3ab0358ec Signed-off-by: Kir Kolyshkin --- pkg/idtools/idtools.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pkg/idtools/idtools.go b/pkg/idtools/idtools.go index b3af7a4226..db1fd1a9d1 100644 --- a/pkg/idtools/idtools.go +++ b/pkg/idtools/idtools.go @@ -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() }