placing defer file.Close() right after opening it (#2306)

This commit is contained in:
karthic rao 2016-07-28 07:52:32 +05:30 committed by Harshavardhana
parent 8b3cb3a0de
commit 6b5fce826b
1 changed files with 4 additions and 3 deletions

View File

@ -492,6 +492,10 @@ func (s *posix) ReadFile(volume string, path string, offset int64, buf []byte) (
}
return 0, err
}
// Close the file descriptor.
defer file.Close()
st, err := file.Stat()
if err != nil {
return 0, err
@ -506,9 +510,6 @@ func (s *posix) ReadFile(volume string, path string, offset int64, buf []byte) (
return 0, err
}
// Close the reader.
defer file.Close()
// Read full until buffer.
m, err := io.ReadFull(file, buf)