One more brick in the wall <g>. Thank you. http://codereview.appspot.com/1773041/diff/7001/8004 File src/pkg/crypto/rand/rand_windows.go (right): http://codereview.appspot.com/1773041/diff/7001/8004#newcode26 src/pkg/crypto/rand/rand_windows.go:26: ...
14 years, 3 months ago
(2010-07-09 05:00:40 UTC)
#3
http://codereview.appspot.com/1773041/diff/7001/8004 File src/pkg/crypto/rand/rand_windows.go (right): http://codereview.appspot.com/1773041/diff/7001/8004#newcode26 src/pkg/crypto/rand/rand_windows.go:26: if r.prov == 0 { On 2010/07/09 05:00:42, brainman ...
14 years, 3 months ago
(2010-07-10 02:43:00 UTC)
#6
http://codereview.appspot.com/1773041/diff/7001/8004
File src/pkg/crypto/rand/rand_windows.go (right):
http://codereview.appspot.com/1773041/diff/7001/8004#newcode26
src/pkg/crypto/rand/rand_windows.go:26: if r.prov == 0 {
On 2010/07/09 05:00:42, brainman wrote:
> I would use once.Do(...) here instead.
By design, since they are solving the essentially same problem, the Unix and
Windows Read methods use the same pattern. If you want to improve the Windows
Read method by using once.Do(...), shouldn't you make the same improvement to
the Unix Read method?
Even if we do use once.Do(...), I would still test for nil or zero. If a pointer
might be nil, now or in the future, I always use a guard to avoid panics; the
same with zero value handles. The file could have been closed or the handle
could have been released.
I included rsc in the list of reviewers because he's the original author of the
Unix-like crypto/rand version.
Issue 569044: code review 569044: crypto/rand: new package
http://codereview.appspot.com/569044
func (r *devReader) Read(b []byte) (n int, err os.Error)
http://codereview.appspot.com/569044/diff/17001/18003#newcode36
> Even if we do use once.Do(...), I would still test for nil or zero. ...
14 years, 3 months ago
(2010-07-11 02:21:39 UTC)
#8
> Even if we do use once.Do(...), I would still test for nil or zero. If a
pointer
> might be nil, now or in the future, I always use a guard to avoid panics; the
> same with zero value handles.
once.Do(...) would take care of everything, that is the sole point of it.
... The file could have been closed or the handle
> could have been released.
Not in the latest version of you code.
> I included rsc in the list of reviewers ...
I'm not fussy either way.
LGTM.
http://codereview.appspot.com/1773041/diff/16001/17002 File src/pkg/crypto/rand/rand.go (right): http://codereview.appspot.com/1773041/diff/16001/17002#newcode16 src/pkg/crypto/rand/rand.go:16: // On Unix-like systems, Reader is initialized to use ...
14 years, 3 months ago
(2010-07-12 21:06:33 UTC)
#11
Issue 1773041: code review 1773041: crypto/rand for Windows
Created 14 years, 3 months ago by peterGo
Modified 14 years, 3 months ago
Reviewers:
Base URL:
Comments: 21