Skip to content

Commit

Permalink
vmdk/*: Fix gosec Errors unhandled issues
Browse files Browse the repository at this point in the history
See,
$ gometalinter --vendor --disable-all --enable=gosec --deadline 10m ./vmdk/...
vmdk/import.go:73::warning: Errors unhandled.,LOW,HIGH (gosec)
vmdk/import.go:75::warning: Errors unhandled.,LOW,HIGH (gosec)
vmdk/import.go:296::warning: Errors unhandled.,LOW,HIGH (gosec)
  • Loading branch information
mjtrangoni committed Feb 10, 2019
1 parent ca9b71a commit f9a2234
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions vmdk/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,16 @@ func stat(name string) (*info, error) {
var buf bytes.Buffer

_, err = io.CopyN(&buf, f, int64(binary.Size(di.Header)))
if err != nil {
return nil, err
}

fi, _ := f.Stat()

_ = f.Close()
fi, err := f.Stat()
if err != nil {
return nil, err
}

err = f.Close()
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -292,9 +297,11 @@ func Import(ctx context.Context, c *vim25.Client, name string, datastore *object
item := info.Items[0] // we only have 1 disk to upload

err = lease.Upload(ctx, item, f, opts)
if err != nil {
return err
}

_ = f.Close()

err = f.Close()
if err != nil {
return err
}
Expand Down

0 comments on commit f9a2234

Please sign in to comment.