random() always returns 0 with srandom(0)

2012-03-21 Thread Jeremy C. Reed
My co-worker was troubleshooting why some of our unittests (that work on multiple operating systems and architectures) failed on OpenBSD and saw that if you call srandom(0) to initialize the RNG, random() will always return 0. (I was able to reproduce this.) If this is expected behaviour,

Re: random() always returns 0 with srandom(0)

2012-03-21 Thread Stuart Henderson
On 2012/03/21 12:37, Jeremy C. Reed wrote: My co-worker was troubleshooting why some of our unittests (that work on multiple operating systems and architectures) failed on OpenBSD and saw that if you call srandom(0) to initialize the RNG, random() will always return 0. (I was able to

Re: random() always returns 0 with srandom(0)

2012-03-21 Thread Theo de Raadt
= div(state[i-1], 127773); Already fixed. CVSROOT:/cvs Module name:src Changes by: mill...@cvs.openbsd.org 2012/03/21 06:36:49 Modified files: lib/libc/stdlib: random.c Log message: Fix a bug where random() always returns 0 when srandom() is seeded with 0. Use 1 and not 0

Re: random() always returns 0 with srandom(0)

2012-03-21 Thread Stuart Henderson
On 2012/03/21 17:41, Stuart Henderson wrote: On 2012/03/21 12:37, Jeremy C. Reed wrote: My co-worker was troubleshooting why some of our unittests (that work on multiple operating systems and architectures) failed on OpenBSD and saw that if you call srandom(0) to initialize the RNG,

Re: random() always returns 0 with srandom(0)

2012-03-21 Thread Brad Smith
] = 123459876; val = div(state[i-1], 127773); I assume you don't read the source-changes list. CVSROOT:/cvs Module name:src Changes by: mill...@cvs.openbsd.org 2012/03/21 06:36:49 Modified files: lib/libc/stdlib: random.c Log message: Fix a bug where random() always returns

Re: random() always returns 0 with srandom(0)

2012-03-21 Thread Darrin Chandler
On Wed, Mar 21, 2012 at 12:37:47PM -0500, Jeremy C. Reed wrote: My co-worker was troubleshooting why some of our unittests (that work on multiple operating systems and architectures) failed on OpenBSD and saw that if you call srandom(0) to initialize the RNG, random() will always return 0.

Re: random() always returns 0 with srandom(0)

2012-03-21 Thread Paul de Weerd
Hi Jeremy, On Wed, Mar 21, 2012 at 12:37:47PM -0500, Jeremy C. Reed wrote: | My co-worker was troubleshooting why some of our unittests (that work on | multiple operating systems and architectures) failed on OpenBSD and saw | that if you call srandom(0) to initialize the RNG, random() will