mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
cleanup: address golangci 'errcheck' issues
Many reports are about closing or removing files. In some cases it is possible to report an error in the logs, in other cases the error can be ignored without potential issues. Test cases have been modified to not remove the temporary files. The temporary directory that is provided by the testing package, is removed once the tests are done. Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
0a22e3a186
commit
bc8b1e792f
@ -45,7 +45,7 @@ func getCgroupPidsFile() (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer cgroup.Close() // #nosec: error on close is not critical here
|
||||
defer cgroup.Close() //nolint:errcheck,nosec // error on close is not critical here
|
||||
|
||||
pidsMax := ""
|
||||
scanner := bufio.NewScanner(cgroup)
|
||||
@ -88,7 +88,7 @@ func GetPIDLimit() (int, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer f.Close() // #nosec: error on close is not critical here
|
||||
defer f.Close() //nolint:errcheck,nosec // error on close is not critical here
|
||||
|
||||
maxPidsStr, err := bufio.NewReader(f).ReadString('\n')
|
||||
if err != nil && !errors.Is(err, io.EOF) {
|
||||
@ -128,7 +128,7 @@ func SetPIDLimit(limit int) error {
|
||||
|
||||
_, err = f.WriteString(limitStr)
|
||||
if err != nil {
|
||||
f.Close() // #nosec: a write error will be more useful to return
|
||||
f.Close() //nolint:errcheck,gosec // a write error will be more useful to return
|
||||
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user