1
0
mirror of https://github.com/golang/go synced 2024-11-22 02:34:40 -07:00

Use defer to unlock mutex in crypto/rand.

R=agl1
CC=golang-dev
https://golang.org/cl/3991045
This commit is contained in:
Anschel Schaffer-Cohen 2011-01-21 10:14:43 -05:00 committed by Adam Langley
parent 49e2888a96
commit 3921d26300

View File

@ -29,15 +29,14 @@ type devReader struct {
func (r *devReader) Read(b []byte) (n int, err os.Error) {
r.mu.Lock()
defer r.mu.Unlock()
if r.f == nil {
f, err := os.Open(r.name, os.O_RDONLY, 0)
if f == nil {
r.mu.Unlock()
return 0, err
}
r.f = f
}
r.mu.Unlock()
return r.f.Read(b)
}