mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
util: log error when closing temp fail fails in GetOMapValue()
gosec-2.3.0 complains about the following: [/go/src/github.com/ceph/ceph-csi/internal/util/cephcmds.go:146] - G307 (CWE-): Deferring unsafe method "*os.File" on type "Close" (Confidence: HIGH, Severity: MEDIUM) > defer tmpFile.Close() By logging the error from Close(), the warning is gone. Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
21bd26ebc4
commit
16c4e33b09
@ -142,7 +142,12 @@ func GetOMapValue(ctx context.Context, monitors string, cr *Credentials, poolNam
|
||||
klog.Errorf(Log(ctx, "failed creating a temporary file for key contents"))
|
||||
return "", err
|
||||
}
|
||||
defer tmpFile.Close()
|
||||
defer func() {
|
||||
ce := tmpFile.Close()
|
||||
if ce != nil {
|
||||
klog.Warningf(Log(ctx, "failed closing temporary file: %s"), ce)
|
||||
}
|
||||
}()
|
||||
defer os.Remove(tmpFile.Name())
|
||||
|
||||
args := []string{
|
||||
|
Loading…
Reference in New Issue
Block a user