svn commit: r241475 - stable/8/lib/libc/stdlib

Eitan Adler eadler at FreeBSD.org
Fri Oct 12 02:12:53 UTC 2012


Author: eadler
Date: Fri Oct 12 02:12:52 2012
New Revision: 241475
URL: http://svn.freebsd.org/changeset/base/241475

Log:
  MFC r241373:
  	Remove undefined behavior from sranddev() and
  	srandomdev(). This doesn't actually work
  	with any modern C compiler:
  
  	In particular, both clang and modern gcc
  	verisons silently elide any xor operation
  	with 'junk'.
  
  Approved by:	cperciva (implicit)

Modified:
  stable/8/lib/libc/stdlib/rand.c
Directory Properties:
  stable/8/lib/libc/   (props changed)

Modified: stable/8/lib/libc/stdlib/rand.c
==============================================================================
--- stable/8/lib/libc/stdlib/rand.c	Fri Oct 12 02:10:27 2012	(r241474)
+++ stable/8/lib/libc/stdlib/rand.c	Fri Oct 12 02:12:52 2012	(r241475)
@@ -130,10 +130,9 @@ sranddev()
 
 	if (!done) {
 		struct timeval tv;
-		unsigned long junk;
 
 		gettimeofday(&tv, NULL);
-		srand((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec ^ junk);
+		srand((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec);
 	}
 }
 


More information about the svn-src-stable-8 mailing list