Subject: Re: [PATCH mh/lockfile-retry] lockfile: replace random() by rand()

From: Michael Haggerty <[email-masked]>
Date: Thu, 04 Jun 2015 13:42:38 +0200

On 06/04/2015 10:40 AM, Johannes Sixt wrote:
> Am 30.05.2015 um 19:12 schrieb Junio C Hamano:
>> Johannes Sixt <[email-masked]> writes:
>>
>>> There you have it: Look the other way for a while, and people start
>>> using exotic stuff... ;)
>>
>> Is it exotic to have random/srandom?  Both are in POSIX and 4BSD;
>> admittedly rand/srand are written down in C89 and later, so they
>> might be more portable, but I recall the prevailing wisdom is to
>> favor random over rand for quality of randomness and portability, so
>> I am wondering if it may be a better approach to keep the code as-is
>> and do a compat/random.c based on either rand/srand (or use posix
>> sample implementation [*1*]).
> 
> For our purposes here, the linear congruence of rand() is certainly
> sufficient. At this time, compatibility functions for random/srandom
> would just mean a lot of work for little gain.

We *certainly* don't require high-quality random numbers for this
application. Regarding portability, there is one definite point in favor
of rand() (it's available on Windows) vs. Junio's recollection that
random() might have portability advantages, presumably on other platforms.

Maybe the easiest thing would be to switch to using rand() and see if
the OS/2 and VMS users complain ;-)

Michael

-- 
Michael Haggerty
[email-masked]