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:
Niels de Vos
2025-05-02 17:33:29 +02:00
committed by mergify[bot]
parent 0a22e3a186
commit bc8b1e792f
19 changed files with 131 additions and 71 deletions

View File

@ -135,7 +135,7 @@ func fsyncEncryptedDirectory(dirPath string) error {
if err != nil {
return err
}
defer dir.Close()
defer dir.Close() //nolint:errcheck // still open? sync may have returned an error too
return dir.Sync()
}
@ -284,7 +284,7 @@ func getInodeEncryptedAttribute(p string) (bool, error) {
if err != nil {
return false, err
}
defer file.Close()
defer file.Close() //nolint:errcheck // failed to close, assume SYS_IOCTL returned an error too
var attr int
_, _, errno := unix.Syscall(unix.SYS_IOCTL, file.Fd(), unix.FS_IOC_GETFLAGS,