Skip to content

Commit

Permalink
Merge pull request #249 from mogren/fix-defer-close
Browse files Browse the repository at this point in the history
Return the err from f.Close()
  • Loading branch information
mattlandis authored Jan 8, 2019
2 parents c322c8d + ef47f01 commit 9365868
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/networkutils/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,13 @@ func (n *linuxNetwork) setProcSys(key, value string) error {
if err != nil {
return err
}
defer f.Close()
_, err = f.WriteString(value)
if err != nil {
// If the write failed, just close
_ = f.Close()
return err
}
return nil
return f.Close()
}

type iptablesRule struct {
Expand Down

0 comments on commit 9365868

Please sign in to comment.