From owner-svn-src-stable-9@FreeBSD.ORG Fri Oct 12 02:12:53 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E49FB53E; Fri, 12 Oct 2012 02:12:53 +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 CD3E28FC1A; 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 q9C2CrLs023981; 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 q9C2Crst023978; Fri, 12 Oct 2012 02:12:53 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201210120212.q9C2Crst023978@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-9@freebsd.org Subject: svn commit: r241476 - stable/9/lib/libc/stdlib X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable 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: 241476 URL: http://svn.freebsd.org/changeset/base/241476 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/9/lib/libc/stdlib/rand.c stable/9/lib/libc/stdlib/random.c Directory Properties: stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/stdlib/rand.c ============================================================================== --- stable/9/lib/libc/stdlib/rand.c Fri Oct 12 02:12:52 2012 (r241475) +++ stable/9/lib/libc/stdlib/rand.c Fri Oct 12 02:12:53 2012 (r241476) @@ -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); } } Modified: stable/9/lib/libc/stdlib/random.c ============================================================================== --- stable/9/lib/libc/stdlib/random.c Fri Oct 12 02:12:52 2012 (r241475) +++ stable/9/lib/libc/stdlib/random.c Fri Oct 12 02:12:53 2012 (r241476) @@ -315,10 +315,9 @@ srandomdev() if (!done) { struct timeval tv; - volatile unsigned long junk; gettimeofday(&tv, NULL); - srandom((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec ^ junk); + srandom((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec); return; }