From owner-cvs-all@FreeBSD.ORG Sat Jul 23 02:01:22 2005 Return-Path: X-Original-To: cvs-all@FreeBSD.ORG Delivered-To: cvs-all@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D6B3316A41F; Sat, 23 Jul 2005 02:01:22 +0000 (GMT) (envelope-from grog@lemis.com) Received: from blackwater.lemis.com (wantadilla.lemis.com [192.109.197.135]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3AAD343D46; Sat, 23 Jul 2005 02:01:22 +0000 (GMT) (envelope-from grog@lemis.com) Received: by blackwater.lemis.com (Postfix, from userid 1004) id 9EA1A86DDB; Sat, 23 Jul 2005 11:31:20 +0930 (CST) Date: Sat, 23 Jul 2005 11:31:20 +0930 From: Greg 'groggy' Lehey To: Andrey Chernov , src-committers@FreeBSD.ORG, cvs-src@FreeBSD.ORG, cvs-all@FreeBSD.ORG Message-ID: <20050723020120.GV842@wantadilla.lemis.com> References: <200507230146.j6N1koqL061690@repoman.freebsd.org> <20050723015517.GA28428@nagual.pp.ru> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="O7hm+SMpb/lu0d4d" Content-Disposition: inline In-Reply-To: <20050723015517.GA28428@nagual.pp.ru> User-Agent: Mutt/1.4.2.1i Organization: The FreeBSD Project Phone: +61-8-8388-8286 Fax: +61-8-8388-8725 Mobile: +61-418-838-708 WWW-Home-Page: http://www.FreeBSD.org/ X-PGP-Fingerprint: 9A1B 8202 BCCE B846 F92F 09AC 22E6 F290 507A 4223 Cc: Subject: Re: cvs commit: src/games/fortune/fortune fortune.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jul 2005 02:01:23 -0000 --O7hm+SMpb/lu0d4d Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Saturday, 23 July 2005 at 5:55:17 +0400, Andrey A. Chernov wrote: > On Sat, Jul 23, 2005 at 01:46:50AM +0000, Greg Lehey wrote: >> grog 2005-07-23 01:46:50 UTC >> >> FreeBSD src repository >> >> Modified files: >> games/fortune/fortune fortune.c >> Log: >> Use a random number to seed the random number generator. Goodby, Rush >> Limbaugh. >> >> This should have already worked properly if random(4) has been >> initialized correctly, but it seems that this is frequently not the >> case. Instead, use the microsecond part of the current time as the >> seed. > > It is already properly and truly randomly initialized, instead of > any microseconds tricks. Theoretically, yes, as I mentioned. > Do you miss srandomdev(); here? No, it was there: init_prob(); - srandomdev(); + gettimeofday (&now, NULL); + srandom (now.tv_usec); But for whatever reasons, many systems seem to have incorrect random(4) initialization. You'll recall the debate about removing Rush Limbaugh fortunes recently because, for some reason related to this issue, his fortunes kept popping up. This is the only place where it seems to make any difference, so it's easier to use a different seed. Greg -- The virus once contained in this message has lost interest in life, shrivelled up and died. LEMIS anti-virus has given it an appropriate burial. For further details see http://www.lemis.com/grog/lemis-virus.html Finger grog@FreeBSD.org for PGP public key. See complete headers for address and phone numbers. --O7hm+SMpb/lu0d4d Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (FreeBSD) iD8DBQFC4aTwIubykFB6QiMRAtzNAJ4uI4pscGJfSIf9vR+yUtAIL4jDcACgmwVi T+CPqGfKw5dAWdm/uL4mtxw= =xx6A -----END PGP SIGNATURE----- --O7hm+SMpb/lu0d4d--