From: Anschel Schaffer-Cohen Date: Fri, 21 Jan 2011 15:14:43 +0000 (-0500) Subject: Use defer to unlock mutex in crypto/rand. X-Git-Tag: weekly.2011-02-01~112 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3921d26300cb61e31657c1732fff92dad6b91712;p=gostls13.git Use defer to unlock mutex in crypto/rand. R=agl1 CC=golang-dev https://golang.org/cl/3991045 --- diff --git a/src/pkg/crypto/rand/rand_unix.go b/src/pkg/crypto/rand/rand_unix.go index ff16f25547..900b573305 100644 --- a/src/pkg/crypto/rand/rand_unix.go +++ b/src/pkg/crypto/rand/rand_unix.go @@ -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) }