svn commit: r252648 - head/lib/libc/stdlib

Andrey A. Chernov ache at FreeBSD.org
Wed Jul 3 23:27:05 UTC 2013


Author: ache
Date: Wed Jul  3 23:27:04 2013
New Revision: 252648
URL: http://svnweb.freebsd.org/changeset/base/252648

Log:
  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

Modified:
  head/lib/libc/stdlib/rand.c

Modified: head/lib/libc/stdlib/rand.c
==============================================================================
--- head/lib/libc/stdlib/rand.c	Wed Jul  3 23:24:53 2013	(r252647)
+++ head/lib/libc/stdlib/rand.c	Wed Jul  3 23:27:04 2013	(r252648)
@@ -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);
 }
 


More information about the svn-src-head mailing list