From owner-svn-src-stable@FreeBSD.ORG Fri Oct 12 02:12:54 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0C97C53F; Fri, 12 Oct 2012 02:12:54 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E84638FC1B; Fri, 12 Oct 2012 02:12:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q9C2CrSE023985; Fri, 12 Oct 2012 02:12:53 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q9C2Creo023983; Fri, 12 Oct 2012 02:12:53 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201210120212.q9C2Creo023983@svn.freebsd.org> From: Eitan Adler Date: Fri, 12 Oct 2012 02:12:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Subject: svn commit: r241477 - stable/7/lib/libc/stdlib X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Oct 2012 02:12:54 -0000 Author: eadler Date: Fri Oct 12 02:12:53 2012 New Revision: 241477 URL: http://svn.freebsd.org/changeset/base/241477 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/7/lib/libc/stdlib/rand.c Directory Properties: stable/7/lib/libc/ (props changed) Modified: stable/7/lib/libc/stdlib/rand.c ============================================================================== --- stable/7/lib/libc/stdlib/rand.c Fri Oct 12 02:12:53 2012 (r241476) +++ stable/7/lib/libc/stdlib/rand.c Fri Oct 12 02:12:53 2012 (r241477) @@ -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); } }