cleanup: resolve errorlint issues

This commit resolves errorlint issues
which checks for the code that will cause
problems with the error wrapping scheme.

Updates: #1586

Signed-off-by: Yati Padia <ypadia@redhat.com>
This commit is contained in:
Yati Padia
2021-07-10 16:15:11 +05:30
committed by mergify[bot]
parent bfda5fa57f
commit 3469dfc753
8 changed files with 23 additions and 22 deletions

View File

@ -18,6 +18,7 @@ package util
import (
"bufio"
"errors"
"fmt"
"io"
"os"
@ -78,7 +79,7 @@ func GetPIDLimit() (int, error) {
defer f.Close() // #nosec: error on close is not critical here
maxPidsStr, err := bufio.NewReader(f).ReadString('\n')
if err != nil && err != io.EOF {
if err != nil && !errors.Is(err, io.EOF) {
return 0, err
}
maxPidsStr = strings.TrimRight(maxPidsStr, "\n")

View File

@ -151,7 +151,7 @@ func GetTopologyFromRequest(
err := json.Unmarshal([]byte(strings.Replace(topologyPoolsStr, "\n", " ", -1)), &topologyPools)
if err != nil {
return nil, nil, fmt.Errorf(
"failed to parse JSON encoded topology constrained pools parameter (%s): %v",
"failed to parse JSON encoded topology constrained pools parameter (%s): %w",
topologyPoolsStr,
err)
}

View File

@ -226,7 +226,7 @@ func TestFindPoolAndTopology(t *testing.T) {
checkOutput := func(err error, poolName string, topoSegment map[string]string) error {
if err != nil {
return fmt.Errorf("expected success, got err (%v)", err)
return fmt.Errorf("expected success, got err (%w)", err)
}
if poolName != pool1 || !(len(topoSegment) == 2) &&
topoSegment[topologyPrefix+"/"+label1] == l1Value1 &&