diff options
author | ache <ache@FreeBSD.org> | 2013-07-03 23:27:04 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2013-07-03 23:27:04 +0000 |
commit | bb909148e91fe6038deabe6aec889b349d126851 (patch) | |
tree | fdd0c9e177d7bd5e15c9612d1cb489593d54b6ae | |
parent | bfcf8b6dd678beced16df63a3c17f7740eebbe86 (diff) | |
download | FreeBSD-src-bb909148e91fe6038deabe6aec889b349d126851.zip FreeBSD-src-bb909148e91fe6038deabe6aec889b349d126851.tar.gz |
In addition to prev. commit, for repeated rand_r(3) calls don't forget
to compensate back at the end incremented at the start internal
state.
MFC after: 2 weeks
-rw-r--r-- | lib/libc/stdlib/rand.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/libc/stdlib/rand.c b/lib/libc/stdlib/rand.c index 676c95e..58b3753 100644 --- a/lib/libc/stdlib/rand.c +++ b/lib/libc/stdlib/rand.c @@ -90,7 +90,11 @@ rand_r(unsigned int *ctx) #endif int r = do_rand(&val); - *ctx = (unsigned int) val; +#ifdef USE_WEAK_SEEDING + *ctx = (unsigned int)val; +#else + *ctx = (unsigned int)(val - 1); +#endif return (r); } |