cvs commit: src/games/fortune/fortune fortune.c

Greg 'groggy' Lehey grog at FreeBSD.org
Sat Jul 23 02:01:23 GMT 2005


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 at FreeBSD.org for PGP public key.
See complete headers for address and phone numbers.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/cvs-all/attachments/20050723/2247346a/attachment.bin


More information about the cvs-all mailing list